#include "lclintMacros.nf"#include "llbasic.h"#include <string.h>#include "cpp.h"#include "cpplib.h"#include "cpphash.h"Go to the source code of this file.
Defines | |
| #define | hashStep(old, c) (((old) << 2) + (unsigned int) (c)) |
| #define | makePositive(v) ((v) & 0x7fffffff) |
Typedefs | |
| typedef HASHNODE* | o_HASHNODE |
Functions | |
| void | cppReader_saveHashtab () |
| void | cppReader_restoreHashtab () |
| int | hashf (const char *name, int len, int hashsize) |
| HASHNODE* | cppReader_lookup (char *name, int len, int hash) |
| HASHNODE* | cppReader_lookupExpand (char *name, int len, int hash) |
| void | cppReader_deleteMacro (HASHNODE *hp) |
| HASHNODE* | cppReader_install (char *name, int len, enum node_type type, int ivalue, char *value, int hash) |
| HASHNODE* | cppReader_installMacro (char *name, int len, struct definition *defn, int hash) |
| void | cppReader_hashCleanup (void) |
|
|
Definition at line 71 of file cpphash.c. Referenced by hashf(). |
|
|
Definition at line 74 of file cpphash.c. Referenced by hashf(). |
|
|
|
|
|
Definition at line 346 of file cpphash.c. Referenced by cppDoUndefine(), and cppReader_hashCleanup(). 00347 {
00348 if (hp->prev != NULL)
00349 {
00350 /*@-mustfree@*/
00351 hp->prev->next = hp->next;
00352 /*@=mustfree@*/
00353 /*@-branchstate@*/
00354 } /*@=branchstate@*/
00355
00356 if (hp->next != NULL)
00357 {
00358 hp->next->prev = hp->prev;
00359 }
00360
00361 /* make sure that the bucket chain header that
00362 the deleted guy was on points to the right thing afterwards. */
00363 if (hp == *hp->bucket_hdr) {
00364 *hp->bucket_hdr = hp->next;
00365 }
00366
00367 if (hp->type == T_MACRO)
00368 {
00369 DEFINITION *d = hp->value.defn;
00370 struct reflist *ap, *nextap;
00371
00372 for (ap = d->pattern; ap != NULL; ap = nextap)
00373 {
00374 nextap = ap->next;
00375 sfree (ap);
00376 }
00377
00378 if (d->nargs >= 0)
00379 {
00380 sfree (d->args.argnames);
00381 }
00382 }
00383
00384 /*@-dependenttrans@*/ /*@-exposetrans@*/ /*@-compdestroy@*/
00385 sfree (hp);
00386 /*@=dependenttrans@*/ /*@=exposetrans@*/ /*@=compdestroy@*/
00387 }
|
|
|
Definition at line 481 of file cpphash.c. Referenced by cppCleanup(). 00482 {
00483 int i;
00484
00485 for (i = CPP_HASHSIZE; --i >= 0; )
00486 {
00487 while (hashtab[i] != NULL)
00488 {
00489 cppReader_deleteMacro (hashtab[i]);
00490 }
00491 }
00492 }
|
|
|
Definition at line 402 of file cpphash.c. Referenced by cppReader_installMacro(). 00404 {
00405 HASHNODE *hp;
00406 int i, bucket;
00407 char *p, *q;
00408
00409 if (len < 0) {
00410 p = name;
00411
00412 while (isIdentifierChar (*p))
00413 {
00414 p++;
00415 }
00416
00417 len = p - name;
00418 }
00419
00420 if (hash < 0)
00421 {
00422 hash = hashf (name, len, CPP_HASHSIZE);
00423 }
00424
00425 i = sizeof (*hp) + len + 1;
00426
00427
00428 hp = (HASHNODE *) dmalloc (size_fromInt (i));
00429 bucket = hash;
00430 hp->bucket_hdr = &hashtab[bucket];
00431
00432 hp->next = hashtab[bucket];
00433 hp->prev = NULL;
00434
00435 if (hp->next != NULL)
00436 {
00437 hp->next->prev = hp;
00438 }
00439
00440 hashtab[bucket] = hp;
00441
00442 hp->type = type;
00443 hp->length = len;
00444
00445 if (hp->type == T_CONST)
00446 {
00447 hp->value.ival = ivalue;
00448 llassert (value == NULL);
00449 }
00450 else
00451 {
00452 hp->value.cpval = value;
00453 }
00454
00455 {
00456 char *tmp = ((char *) hp) + sizeof (*hp);
00457 p = tmp;
00458 q = name;
00459
00460 for (i = 0; i < len; i++)
00461 {
00462 *p++ = *q++;
00463 }
00464
00465 tmp[len] = '\0';
00466 hp->name = cstring_fromChars (tmp);
00467 }
00468
00469 /*@-mustfree@*/ /*@-uniondef@*/ /*@-compdef@*/
00470 return hp;
00471 /*@=mustfree@*/ /*@=uniondef@*/ /*@=compdef@*/
00472 }
|
|
|
Definition at line 474 of file cpphash.c. 00476 {
00477 return cppReader_install (name, len, T_MACRO, 0, (char *) defn, hash);
00478 }
|
|
|
Definition at line 271 of file cpphash.c. Referenced by cppDoUndefine(), and cppReader_lookupExpand(). 00272 {
00273 const char *bp;
00274 HASHNODE *bucket;
00275
00276 if (len < 0)
00277 {
00278 for (bp = name; isIdentifierChar (*bp); bp++)
00279 {
00280 ;
00281 }
00282
00283 len = bp - name;
00284 }
00285
00286 if (hash < 0)
00287 {
00288 hash = hashf (name, len, CPP_HASHSIZE);
00289 }
00290
00291 bucket = hashtab[hash];
00292
00293 while (bucket != NULL)
00294 {
00295 if (bucket->length == len &&
00296 cstring_equalLen (bucket->name, cstring_fromChars (name), len))
00297 {
00298 return bucket;
00299 }
00300
00301 bucket = bucket->next;
00302 }
00303
00304 return NULL;
00305 }
|
|
|
Definition at line 307 of file cpphash.c. Referenced by cppGetToken(). 00308 {
00309 HASHNODE *node = cppReader_lookup (name, len, hash);
00310
00311 DPRINTF (("Lookup expand: %s", name));
00312
00313 if (node != NULL)
00314 {
00315 if (node->type == T_MACRO)
00316 {
00317 DEFINITION *defn = (DEFINITION *) node->value.defn;
00318
00319 DPRINTF (("Check macro..."));
00320
00321 if (defn->noExpand) {
00322 DPRINTF (("No expand!"));
00323 return NULL;
00324 }
00325 }
00326 }
00327
00328 return node;
00329 }
|
|
|
Definition at line 92 of file cpphash.c. Referenced by cppProcess(). 00093 {
00094 int i;
00095
00096 for (i = 0; i < CPP_HASHSIZE; i++) {
00097 /* HashNode_delete (hashtab[i]); */
00098 hashtab[i] = HashNode_copy (ohashtab[i], &hashtab[i], NULL);
00099 }
00100 }
|
|
|
Definition at line 82 of file cpphash.c. Referenced by cppReader_saveDefinitions(). 00083 {
00084 int i;
00085
00086 for (i = 0; i < CPP_HASHSIZE; i++)
00087 {
00088 ohashtab[i] = HashNode_copy (hashtab[i], &ohashtab[i], NULL);
00089 }
00090 }
|
|
|
why doesn't lclint report an error for this? Definition at line 248 of file cpphash.c. Referenced by FNAME_HASHSIZE(), cppReader_install(), and cppReader_lookup(). 00249 {
00250 unsigned int r = 0;
00251
00252 while (len-- != 0)
00253 {
00254 r = hashStep (r, *name++);
00255 }
00256
00257 return (int) (makePositive (r) % hashsize);
00258 }
|
1.2.3 written by Dimitri van Heesch,
© 1997-2000