Commit | Line | Data |
---|---|---|
2baf4634 MB |
1 | This patch originates from the Debian project, see https://www.debian.org/ |
2 | ||
3 | 18dbpagesize_binpower.dpatch by <hesso@pool.math.tu-berlin.de> | |
4 | ||
5 | ||
6 | Make sure that the pagesize passed to db__set_pagesize() is a power of two. | |
7 | ||
8 | nvi stores the content of files in BDB database structures. When initiating a | |
9 | file, it picks a page size for the database to fit the file within 15 pages, | |
10 | with a minimal page size of 1K and maximal of 10K. | |
11 | ||
12 | In vanilla nvi, this size is calculated as a multiple of 1024. Modern versions | |
13 | of BDB, however, require the page size of a database to be a power of two, which | |
14 | this patch addresses, ridding us of the following message: | |
15 | ||
16 | BDB0511 page sizes must be a power-of-2 | |
17 | ||
18 | --- nvi-1.81.6.orig/common/exf.c 2009-03-09 01:48:01.695862889 +0100 | |
19 | +++ nvi-1.81.6/common/exf.c 2009-03-09 10:42:41.147866272 +0100 | |
20 | @@ -249,11 +249,10 @@ | |
21 | * (vi should have good locality) or smaller than 1K. | |
22 | */ | |
23 | psize = ((sb.st_size / 15) + 1023) / 1024; | |
24 | - if (psize > 10) | |
25 | - psize = 10; | |
26 | - if (psize == 0) | |
27 | - psize = 1; | |
28 | - psize *= 1024; | |
29 | + if (psize >= 8) psize=8<<10; | |
30 | + else if (psize >= 4) psize=4<<10; | |
31 | + else if (psize >= 2) psize=2<<10; | |
32 | + else psize=1<<10; | |
33 | ||
34 | F_SET(ep, F_DEVSET); | |
35 | ep->mdev = sb.st_dev; |