Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!samsung!uunet!comp.vuw.ac.nz!ajv From: Andrew.Vignaux@comp.vuw.ac.nz (Andrew Vignaux) Newsgroups: comp.lang.perl Subject: Re: DBM problems in pl.28 Message-ID: <1990Aug18.024648.19269@comp.vuw.ac.nz> Date: 18 Aug 90 02:46:48 GMT References: <1414@esatst.yc.estec.nl> Sender: news@comp.vuw.ac.nz (News Admin) Organization: Comp Sci, Victoria University, Wellington, New Zealand. Lines: 57 In article <1414@esatst.yc.estec.nl>, arne@yc.estec.nl (Arne Lundberg) writes: |> Since installing patch 28 I have found a problem with dbm files, I think the problem is in the lazy array creation that went in in pl.28. hfetch() only creates the array if the access is an lval and it hasn't been stored into already. Unfortunately, dbm files can already have stuff in them. The local fix: if (!tb->tbl_array) { ! if (lval) Newz(503,tb->tbl_array, tb->tbl_max + 1, HENT*); to if (!tb->tbl_array) { ! if (lval || tb->tbl_dbm) Newz(503,tb->tbl_array, tb->tbl_max + 1, HENT*); works, but it means that dbmopen(FOO,"foo",0666); print defined(%FOO), "\n"; still prints 0. Here's a completely unofficial patch that (I think) fixes this problem. I'm posting this because I can't believe I'm the only one who depends on dbm files in perl. I don't want to go back to 18 because of the lack of dbmopen(FOO, "foo", undef) ;-) *** ./hash.c~ Tue Aug 14 21:17:53 1990 --- ./hash.c Sat Aug 18 14:22:50 1990 *************** *** 551,556 **** --- 551,558 ---- } tb->tbl_dbm = dbminit(fname) >= 0; #endif + if (!tb->tbl_array && tb->tbl_dbm != 0) + Newz(507,tb->tbl_array, tb->tbl_max + 1, HENT*); return tb->tbl_dbm != 0; } This fix also means that dbmopen(FOO,"foo",undef); print defined(%FOO), "\n"; and dbmopen(BAR,"bar",0666); print defined(%BAR), "\n"; prints 0 if "foo.dir" doesn't exist, or "bar.{dir,pag}" can't be created. Both "fixes" pass make test on a MORE/bsd hp300. Andrew -- Domain address: Andrew.Vignaux@comp.vuw.ac.nz