aboutsummaryrefslogtreecommitdiff
path: root/editors/nvi/patch-power-of-2
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-07-12 21:24:30 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-07-12 21:25:57 +0200
commit3fa50c8878d666810c9ab33f33c4eef6c64cdd71 (patch)
tree4c76fd35415473816ce587f0bd9d4ce616d8789c /editors/nvi/patch-power-of-2
parentecced53ec35de37f82bd8329ae487fdb5251a136 (diff)
downloadpatches-3fa50c8878d666810c9ab33f33c4eef6c64cdd71.tar.gz
editors/nvi: Add patch-power-of-2
See https://trac.macports.org/ticket/22228.
Diffstat (limited to 'editors/nvi/patch-power-of-2')
-rw-r--r--editors/nvi/patch-power-of-231
1 files changed, 31 insertions, 0 deletions
diff --git a/editors/nvi/patch-power-of-2 b/editors/nvi/patch-power-of-2
new file mode 100644
index 0000000..5f6aaff
--- /dev/null
+++ b/editors/nvi/patch-power-of-2
@@ -0,0 +1,31 @@
+$NetBSD
+
+Get rid of "page sizes must be a power-of-2" warning when loading a file.
+
+--- common/exf.c.orig 2021-07-12 21:21:22.247541289 +0200
++++ common/exf.c
+@@ -228,15 +228,17 @@ file_init(SCR *sp, FREF *frp, char *rcv_name, int flags)
+ /*
+ * XXX
+ * A seat of the pants calculation: try to keep the file in
+- * 15 pages or less. Don't use a page size larger than 10K
++ * 15 pages or less. Don't use a page size larger than 16K
+ * (vi should have good locality) or smaller than 1K.
+ */
+- psize = ((sb.st_size / 15) + 1023) / 1024;
+- if (psize > 10)
+- psize = 10;
+- if (psize == 0)
+- psize = 1;
+- psize *= 1024;
++ psize = (sb.st_size > 0) ? ffsl(sb.st_size - 1) + 1 : 0;
++ /* Do these very low limits make sense anymore? */
++ if (psize < 10)
++ psize = 10; /* 1K */
++ if (psize > 14)
++ psize = 14; /* 16K */
++ /* Keep page size on power of 2 boundary to keep db4 happy. */
++ psize = 1 << psize;
+
+ F_SET(ep, F_DEVSET);
+ ep->mdev = sb.st_dev;