From: kipp@shonanblue.ne.jp Date: Mon, 6 Nov 2000 13:30:55 +0000 (-0800) Subject: Fake support of holey files in win/dosish platforms. X-Git-Tag: accepted/trunk/20130322.191538~33723 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f6bbbfc7ed5949b4cc3153db422c0245e2b48587;p=platform%2Fupstream%2Fperl.git 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 --- diff --git a/ext/SDBM_File/sdbm/sdbm.c b/ext/SDBM_File/sdbm/sdbm.c index 64c75cb..d41c770 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)