summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkipp@shonanblue.ne.jp <kipp@shonanblue.ne.jp>2000-11-06 05:30:55 -0800
committerJarkko Hietaniemi <jhi@iki.fi>2000-11-07 00:32:22 +0000
commit2fb00bc405e59cf01da8f05073c5fcc1178bb9be (patch)
tree7c419dd4c45c5796c1b1341e86632dfc322cdcc6
parentd785950e9638864cb0ef02b2b0b95e52abe662d6 (diff)
downloadperl-2fb00bc405e59cf01da8f05073c5fcc1178bb9be.tar.gz
Fake support of holey files in win/dosish platforms.
Subject: SDBM_File under MS-Windows95/98 does not work correctly. (APR#1302) Message-Id: <200011062130.eA6LUpZ17387@smtp3.ActiveState.com> p4raw-id: //depot/perl@7586
-rw-r--r--ext/SDBM_File/sdbm/sdbm.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/ext/SDBM_File/sdbm/sdbm.c b/ext/SDBM_File/sdbm/sdbm.c
index 64c75cbb20..d41c770dfb 100644
--- a/ext/SDBM_File/sdbm/sdbm.c
+++ b/ext/SDBM_File/sdbm/sdbm.c
@@ -283,6 +283,10 @@ makroom(register DBM *db, long int hash, int need)
{
long newp;
char twin[PBLKSIZ];
+#if defined(DOSISH) || defined(WIN32)
+ char zer[PBLKSIZ];
+ long oldtail;
+#endif
char *pag = db->pagbuf;
char *New = twin;
register int smax = SPLTMAX;
@@ -305,6 +309,23 @@ makroom(register DBM *db, long int hash, int need)
* still looking at the page of interest. current page is not updated
* here, as sdbm_store will do so, after it inserts the incoming pair.
*/
+
+#if defined(DOSISH) || defined(WIN32)
+ /*
+ * Fill hole with 0 if made it.
+ * (hole is NOT read as 0)
+ */
+ oldtail = lseek(db->pagf, 0L, SEEK_END);
+ memset(zer, 0, PBLKSIZ);
+ while (OFF_PAG(newp) > oldtail) {
+ if (lseek(db->pagf, 0L, SEEK_END) < 0 ||
+ write(db->pagf, zer, PBLKSIZ) < 0) {
+
+ return 0;
+ }
+ oldtail += PBLKSIZ;
+ }
+#endif
if (hash & (db->hmask + 1)) {
if (lseek(db->pagf, OFF_PAG(db->pagbno), SEEK_SET) < 0
|| write(db->pagf, db->pagbuf, PBLKSIZ) < 0)