zsh-workers
 help / color / mirror / code / Atom feed
* [bug] gdbm tied hashes always consider members set
@ 2021-07-25 17:06 Stephane Chazelas
  2021-07-26 23:29 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Stephane Chazelas @ 2021-07-25 17:06 UTC (permalink / raw)
  To: Zsh hackers list

$ zmodload zsh/db/gdbm
$ ztie -d db/gdbm -f new.db a
$ typeset -p a
typeset -A a=( )
$ echo ${+a[x]}
1
$ echo ${a[x]+yes}
yes

Members are always consider set even when they're not.

-- 
Stephane


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [bug] gdbm tied hashes always consider members set
  2021-07-25 17:06 [bug] gdbm tied hashes always consider members set Stephane Chazelas
@ 2021-07-26 23:29 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2021-07-26 23:29 UTC (permalink / raw)
  To: Zsh hackers list

On Sun, Jul 25, 2021 at 10:07 AM Stephane Chazelas
<stephane@chazelas.org> wrote:
>
> Members are always consider set even when they're not.

It seems to be this easy:

diff --git a/Src/Modules/db_gdbm.c b/Src/Modules/db_gdbm.c
index b8e7c76c6..84fdfa905 100644
--- a/Src/Modules/db_gdbm.c
+++ b/Src/Modules/db_gdbm.c
@@ -332,6 +332,8 @@ gdbmgetfn(Param pm)

         /* Can return pointer, correctly saved inside hash */
         return pm->u.str;
+    } else {
+      pm->node.flags |= PM_DEFAULTED;
     }

     /* Free key */


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-26 23:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-25 17:06 [bug] gdbm tied hashes always consider members set Stephane Chazelas
2021-07-26 23:29 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).