error in JudyHS man page

Bug #771440 reported by Jeff Norden on 2011-04-26
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
judy (Ubuntu)
Undecided
Unassigned

Bug Description

There is a minor, but very confusing error in the example code at the end of the JudyHS man page.
The line

               if (*PValue == 0) // check if duplicate

should be changed to

               if (*PValue != 0) // check if duplicate

This is because, as explained earlier in the man page, the value associated with a key is initialized to zero when the key is *not* already in the array. So *PValue==0 is true when the line is *not* a duplicate.

This was reported upstream a couple of years ago, but I doubt if it will be fixed there any time soon. See:
http://sourceforge.net/tracker/?func=detail&aid=2696938&group_id=55753&atid=478138

Maybe if ubuntu fixes this, the correction will be picked up by other distros, and nobody else will waste time puzzling over this as I did.

I'm attaching .c files with the orig and corrected code. If you compile them, you can verify that the corrected code works as expected, and the orig labels every line of the input file as a duplicate.

Thanks,
-Jeff

Jeff Norden (jeff-math) wrote :
Jeff Norden (jeff-math) wrote :
tags: added: manpage
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers