summaryrefslogtreecommitdiffstats
path: root/contrib/less/ch.c
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2007-11-16 22:22:17 +0000
committerdelphij <delphij@FreeBSD.org>2007-11-16 22:22:17 +0000
commite2b0c4a1d9f9f53e73cf7da116a4546c07cde418 (patch)
tree0c9762eeda7d2def39527db440983a3ea2c88c41 /contrib/less/ch.c
parent9680b7d49a594123cfffb2bc9d11614d1a2625d0 (diff)
downloadFreeBSD-src-e2b0c4a1d9f9f53e73cf7da116a4546c07cde418.zip
FreeBSD-src-e2b0c4a1d9f9f53e73cf7da116a4546c07cde418.tar.gz
Virgin import of less v415.
Diffstat (limited to 'contrib/less/ch.c')
-rw-r--r--contrib/less/ch.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/contrib/less/ch.c b/contrib/less/ch.c
index 2ac14d7..eb607d5 100644
--- a/contrib/less/ch.c
+++ b/contrib/less/ch.c
@@ -21,6 +21,12 @@
#include <windows.h>
#endif
+#if HAVE_STAT_INO
+#include <sys/stat.h>
+extern dev_t curr_dev;
+extern ino_t curr_ino;
+#endif
+
typedef POSITION BLOCKNUM;
public int ignore_eoi;
@@ -98,6 +104,8 @@ static int maxbufs = -1;
extern int autobuf;
extern int sigs;
extern int secure;
+extern int screen_trashed;
+extern int follow_mode;
extern constant char helpdata[];
extern constant int size_helpdata;
extern IFILE curr_ifile;
@@ -195,7 +203,7 @@ fch_get()
*/
if (!(ch_flags & CH_CANSEEK))
return ('?');
- if (lseek(ch_file, (off_t)pos, 0) == BAD_LSEEK)
+ if (lseek(ch_file, (off_t)pos, SEEK_SET) == BAD_LSEEK)
{
error("seek error", NULL_PARG);
clear_eol();
@@ -276,6 +284,25 @@ fch_get()
#endif
#endif
slept = TRUE;
+
+#if HAVE_STAT_INO
+ if (follow_mode == FOLLOW_NAME)
+ {
+ /* See whether the file's i-number has changed.
+ * If so, force the file to be closed and
+ * reopened. */
+ struct stat st;
+ int r = stat(get_filename(curr_ifile), &st);
+ if (r == 0 && (st.st_ino != curr_ino ||
+ st.st_dev != curr_dev))
+ {
+ /* screen_trashed=2 causes
+ * make_display to reopen the file. */
+ screen_trashed = 2;
+ return (EOI);
+ }
+ }
+#endif
}
if (sigs)
return (EOI);
@@ -648,7 +675,7 @@ ch_flush()
}
#endif
- if (lseek(ch_file, (off_t)0, 0) == BAD_LSEEK)
+ if (lseek(ch_file, (off_t)0, SEEK_SET) == BAD_LSEEK)
{
/*
* Warning only; even if the seek fails for some reason,
@@ -711,7 +738,7 @@ ch_delbufs()
while (ch_bufhead != END_OF_CHAIN)
{
bp = ch_bufhead;
- bp->next->prev = bp->prev;;
+ bp->next->prev = bp->prev;
bp->prev->next = bp->next;
free(bp);
}
@@ -737,7 +764,7 @@ seekable(f)
return (0);
}
#endif
- return (lseek(f, (off_t)1, 0) != BAD_LSEEK);
+ return (lseek(f, (off_t)1, SEEK_SET) != BAD_LSEEK);
}
/*
OpenPOWER on IntegriCloud