diff options
author | delphij <delphij@FreeBSD.org> | 2007-11-16 22:22:17 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2007-11-16 22:22:17 +0000 |
commit | e2b0c4a1d9f9f53e73cf7da116a4546c07cde418 (patch) | |
tree | 0c9762eeda7d2def39527db440983a3ea2c88c41 /contrib/less/edit.c | |
parent | 9680b7d49a594123cfffb2bc9d11614d1a2625d0 (diff) | |
download | FreeBSD-src-e2b0c4a1d9f9f53e73cf7da116a4546c07cde418.zip FreeBSD-src-e2b0c4a1d9f9f53e73cf7da116a4546c07cde418.tar.gz |
Virgin import of less v415.
Diffstat (limited to 'contrib/less/edit.c')
-rw-r--r-- | contrib/less/edit.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/contrib/less/edit.c b/contrib/less/edit.c index 908f29e..e2e30f2 100644 --- a/contrib/less/edit.c +++ b/contrib/less/edit.c @@ -10,6 +10,9 @@ #include "less.h" +#if HAVE_STAT +#include <sys/stat.h> +#endif public int fd0 = 0; @@ -36,6 +39,11 @@ extern int force_logfile; extern char *namelogfile; #endif +#if HAVE_STAT_INO +public dev_t curr_dev; +public ino_t curr_ino; +#endif + char *curr_altfilename = NULL; static void *curr_altpipe; @@ -178,6 +186,9 @@ close_file() curr_altfilename = NULL; } curr_ifile = NULL_IFILE; +#if HAVE_STAT_INO + curr_ino = curr_dev = 0; +#endif } /* @@ -360,7 +371,6 @@ edit_ifile(ifile) } } } - free(qopen_filename); /* * Get the new ifile. @@ -385,10 +395,23 @@ edit_ifile(ifile) if (namelogfile != NULL && is_tty) use_logfile(namelogfile); #endif +#if HAVE_STAT_INO + /* Remember the i-number and device of the opened file. */ + { + struct stat statbuf; + int r = stat(qopen_filename, &statbuf); + if (r == 0) + { + curr_ino = statbuf.st_ino; + curr_dev = statbuf.st_dev; + } + } +#endif if (every_first_cmd != NULL) ungetsc(every_first_cmd); } + free(qopen_filename); no_display = !any_display; flush(); any_display = TRUE; @@ -657,6 +680,14 @@ reedit_ifile(save_ifile) quit(QUIT_ERROR); } + public void +reopen_curr_ifile() +{ + IFILE save_ifile = save_curr_ifile(); + close_file(); + reedit_ifile(save_ifile); +} + /* * Edit standard input. */ @@ -747,7 +778,7 @@ loop: * Append: open the file and seek to the end. */ logfile = open(filename, OPEN_APPEND); - if (lseek(logfile, (off_t)0, 2) == BAD_LSEEK) + if (lseek(logfile, (off_t)0, SEEK_END) == BAD_LSEEK) { close(logfile); logfile = -1; |