summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/less/less.h2
-rw-r--r--usr.bin/less/os.c33
-rw-r--r--usr.bin/less/prompt.c2
3 files changed, 19 insertions, 18 deletions
diff --git a/usr.bin/less/less.h b/usr.bin/less/less.h
index 2f6959de89c..c0c6fbfc8ac 100644
--- a/usr.bin/less/less.h
+++ b/usr.bin/less/less.h
@@ -118,7 +118,7 @@ void free();
/*
* Special types and constants.
*/
-typedef long POSITION;
+typedef off_t POSITION;
/*
* {{ Warning: if POSITION is changed to other than "long",
* you may have to change some of the printfs which use "%ld"
diff --git a/usr.bin/less/os.c b/usr.bin/less/os.c
index 908d6352fda..2c48f4a0e61 100644
--- a/usr.bin/less/os.c
+++ b/usr.bin/less/os.c
@@ -38,6 +38,7 @@
*/
#include "less.h"
+#include <limits.h>
#include <signal.h>
#include <setjmp.h>
#if HAVE_TIME_H
@@ -188,27 +189,27 @@ errno_message(filename)
}
/*
- * Return the largest possible number that can fit in a long.
+ * Return the largest possible number that can fit in a POSITION.
*/
-#ifdef MAXLONG
- static long
-get_maxlong()
+#ifdef QUAD_MAX
+ static POSITION
+get_maxpos()
{
- return (MAXLONG);
+ return (QUAD_MAX);
}
#else
- static long
-get_maxlong()
+ static POSITION
+get_maxpos()
{
- long n, n2;
+ POSITION n, n2;
/*
* Keep doubling n until we overflow.
* {{ This actually only returns the largest power of two that
- * can fit in a long, but percentage() doesn't really need
+ * can fit in a POSITION, but percentage() doesn't really need
* it any more accurate than that. }}
*/
- n2 = 128; /* Hopefully no maxlong is less than 128! */
+ n2 = 128; /* Hopefully no maxpos is less than 128! */
do {
n = n2;
n2 *= 2;
@@ -218,17 +219,17 @@ get_maxlong()
#endif
/*
- * Return the ratio of two longs, as a percentage.
+ * Return the ratio of two POSITIONs, as a percentage.
*/
public int
percentage(num, den)
- long num, den;
+ POSITION num, den;
{
- static long maxlong100 = 0;
+ static POSITION maxpos100 = 0;
- if (maxlong100 == 0)
- maxlong100 = get_maxlong() / 100;
- if (num > maxlong100)
+ if (maxpos100 == 0)
+ maxpos100 = get_maxpos() / 100;
+ if (num > maxpos100)
return (num / (den/100));
else
return (100*num / den);
diff --git a/usr.bin/less/prompt.c b/usr.bin/less/prompt.c
index 2e0b62cc6bf..6fa74bc04d5 100644
--- a/usr.bin/less/prompt.c
+++ b/usr.bin/less/prompt.c
@@ -98,7 +98,7 @@ setmp()
ap_pos(pos)
POSITION pos;
{
- sprintf(mp, "%ld", (long)pos);
+ sprintf(mp, "%qd", pos);
setmp();
}