From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16097 invoked by alias); 7 Oct 2010 06:29:22 -0000 Received: (qmail 16088 invoked by uid 22791); 7 Oct 2010 06:29:21 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL,BAYES_00,SPF_SOFTFAIL X-Spam-Check-By: sourceware.org Received: from syracuse.mckusick.com (HELO syracuse.mckusick.com) (64.81.247.46) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 07 Oct 2010 06:29:17 +0000 Received: from syracuse.mckusick.com (localhost [127.0.0.1]) by syracuse.mckusick.com (8.14.3/8.14.3/Debian-9.1ubuntu1) with ESMTP id o976SdG3002807; Wed, 6 Oct 2010 23:28:39 -0700 Received: (from hilfingr@localhost) by syracuse.mckusick.com (8.14.3/8.14.3/Submit) id o976SbIj002805; Wed, 6 Oct 2010 23:28:37 -0700 Subject: Re: [RFA] Extend hashed symbol dictionaries to work with Ada From: Paul Hilfinger Reply-To: Hilfinger@adacore.com To: Doug Evans Cc: Hilfinger@adacore.com, Tom Tromey , Joel Brobecker , gdb-patches@sourceware.org In-Reply-To: References: <201010050820.o958Kf42002588@syracuse.mckusick.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Date: Thu, 07 Oct 2010 06:29:00 -0000 Message-ID: <1286432916.2507.24.camel@syracuse.mckusick.com> Mime-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-10/txt/msg00114.txt.bz2 On Wed, 2010-10-06 at 16:59 -0700, Doug Evans wrote: > Hi. I wouldn't mind having a couple of comments added to this function: >=20 Arghh. My mistake. I added a comment to our local version without submitting it. Updating: +/* Produce an unsigned hash value from STRING0 that is consistent + with strcmp_iw, strcmp, and, at least on Ada symbols, wild_match. + That is, two identifiers equivalent according to any of those three + comparison operators hash to the same value. */ + +static unsigned int +dict_hash (const char *string) +{ + /* The Ada-encoded version of a name P1.P2...Pn has either the form + P1__P2__...Pn or _ada_P1__P2__...Pn (where the Pi + are lower-cased identifiers). The (which can be empty) + encodes additional information about the denoted entity. This + routine hashes such names to msymbol_hash_iw(Pn). It actually + does this for a superset of both valid Pi and of , but=20 + in other cases it simply returns msymbol_hash_iw(STRING0). */ ... > > + case '_': > > + if (string[1] =3D=3D '_') > > + { > > + if (((c =3D string[2]) < 'a' || c > 'z') && c !=3D 'O') >=20 > Why does this `if' exist? >=20 Follows from the (newly added) comment above. That condition indicates a __ followed by something that can't be an encoded Ada identifier. We assume it is part of the suffix (as indicated in the comment, we accept a superset of the valid suffixes). > > + return hash; > > + hash =3D 0; >=20 > Why do we restart calculating the hash here? As the comments indicate, we are ignoring the prefix of a qualified name to get wild-matching. Thanks for your comments. Paul