diff options
author | delphij <delphij@FreeBSD.org> | 2009-05-08 23:45:27 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2009-05-08 23:45:27 +0000 |
commit | 40472e4d24727eb8c2cf003fa10c3d4c6a89e22b (patch) | |
tree | a3b19b698e154070851f613743d2c3b6467b5828 /cmdbuf.c | |
parent | d069efd47cacc3156036ed37d5532d6a1d4f55c3 (diff) | |
download | FreeBSD-src-40472e4d24727eb8c2cf003fa10c3d4c6a89e22b.zip FreeBSD-src-40472e4d24727eb8c2cf003fa10c3d4c6a89e22b.tar.gz |
Vendor import of less v429
Diffstat (limited to 'cmdbuf.c')
-rw-r--r-- | cmdbuf.c | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -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); |