From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17745 invoked from network); 1 Dec 1996 16:04:57 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by coral.primenet.com.au with SMTP; 1 Dec 1996 16:04:57 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id KAA06253; Sun, 1 Dec 1996 10:46:32 -0500 (EST) Resent-Date: Sun, 1 Dec 1996 10:46:32 -0500 (EST) From: Zefram Message-Id: <13465.199612011547@stone.dcs.warwick.ac.uk> Subject: hashinfo improvement To: zsh-workers@math.gatech.edu (Z Shell workers mailing list) Date: Sun, 1 Dec 1996 15:47:02 +0000 (GMT) X-Patch: 140 X-Loop: zefram@dcs.warwick.ac.uk X-Stardate: [-31]8508.28 X-US-Congress: Moronic fuckers Content-Type: text Resent-Message-ID: <"o7Pbg3.0.dX1.LXQeo"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2509 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu -----BEGIN PGP SIGNED MESSAGE----- This patch changes the means by which hashinfo lists all the hash tables. Previously it had to know about each table individually, requiring them all to have global scope. This patch causes newhashtable() to put the created hash tables into a linked list, which hashinfo can then walk along. This allows hash tables to be private to a single source file or function, and yet still appear in the debugging output. I have a couple of patches planned that would benefit from this. (Zoltan, are you planning a 3.1.0 release sometime soon?) There are no changes if ZSH_HASH_DEBUG is undefined. -zefram Index: Src/builtin.c =================================================================== RCS file: /home/zefram/usr/cvsroot/zsh/Src/builtin.c,v retrieving revision 1.38 diff -c -r1.38 builtin.c *** Src/builtin.c 1996/11/30 23:34:47 1.38 --- Src/builtin.c 1996/11/30 23:48:56 *************** *** 5697,5736 **** return 0; } - /*** debugging functions ***/ - - #ifdef ZSH_HASH_DEBUG - /**/ - int - bin_hashinfo(char *nam, char **args, char *ops, int func) - { - printf("----------------------------------------------------\n"); - cmdnamtab->printinfo(cmdnamtab); - printf("----------------------------------------------------\n"); - shfunctab->printinfo(shfunctab); - printf("----------------------------------------------------\n"); - builtintab->printinfo(builtintab); - printf("----------------------------------------------------\n"); - paramtab->printinfo(paramtab); - printf("----------------------------------------------------\n"); - compctltab->printinfo(compctltab); - printf("----------------------------------------------------\n"); - aliastab->printinfo(aliastab); - printf("----------------------------------------------------\n"); - reswdtab->printinfo(reswdtab); - printf("----------------------------------------------------\n"); - emkeybindtab->printinfo(emkeybindtab); - printf("----------------------------------------------------\n"); - vikeybindtab->printinfo(vikeybindtab); - printf("----------------------------------------------------\n"); - altkeybindtab->printinfo(altkeybindtab); - printf("----------------------------------------------------\n"); - nameddirtab->printinfo(nameddirtab); - printf("----------------------------------------------------\n"); - return 0; - } - #endif - /**** utility functions -- should go in utils.c ****/ /* Separate an argument into name=value parts, returning them in an * --- 5697,5702 ---- Index: Src/hashtable.c =================================================================== RCS file: /home/zefram/usr/cvsroot/zsh/Src/hashtable.c,v retrieving revision 1.11 diff -c -r1.11 hashtable.c *** Src/hashtable.c 1996/11/08 01:23:07 1.11 --- Src/hashtable.c 1996/12/01 00:03:36 *************** *** 35,40 **** --- 35,44 ---- /* Generic Hash Table functions */ /********************************/ + #ifdef ZSH_HASH_DEBUG + static HashTable firstht, lastht; + #endif + /* Generic hash function */ /**/ *************** *** 58,63 **** --- 62,76 ---- HashTable ht; ht = (HashTable) zcalloc(sizeof *ht); + #ifdef ZSH_HASH_DEBUG + ht->next = NULL; + if(!firstht) + firstht = ht; + ht->last = lastht; + if(lastht) + lastht->next = ht; + lastht = ht; + #endif /* ZSH_HASH_DEBUG */ ht->nodes = (HashNode *) zcalloc(size * sizeof(HashNode)); ht->hsize = size; ht->ct = 0; *************** *** 450,459 **** ht->ct = 0; } - /* Print info about hash table */ - #ifdef ZSH_HASH_DEBUG #define MAXDEPTH 7 /**/ --- 463,472 ---- ht->ct = 0; } #ifdef ZSH_HASH_DEBUG + /* Print info about hash table */ + #define MAXDEPTH 7 /**/ *************** *** 488,494 **** printf("number of hash values with chain of length %d+ : %4d\n", MAXDEPTH, chainlen[MAXDEPTH]); printf("total number of nodes : %4d\n", total); } ! #endif /********************************/ /* Command Hash Table Functions */ --- 501,521 ---- printf("number of hash values with chain of length %d+ : %4d\n", MAXDEPTH, chainlen[MAXDEPTH]); printf("total number of nodes : %4d\n", total); } ! ! /**/ ! int ! bin_hashinfo(char *nam, char **args, char *ops, int func) ! { ! HashTable ht; ! printf("----------------------------------------------------\n"); ! for(ht = firstht; ht; ht = ht->next) { ! ht->printinfo(ht); ! printf("----------------------------------------------------\n"); ! } ! return 0; ! } ! ! #endif /* ZSH_HASH_DEBUG */ /********************************/ /* Command Hash Table Functions */ Index: Src/zsh.h =================================================================== RCS file: /home/zefram/usr/cvsroot/zsh/Src/zsh.h,v retrieving revision 1.28 diff -c -r1.28 zsh.h *** Src/zsh.h 1996/11/22 22:59:33 1.28 --- Src/zsh.h 1996/11/30 23:42:59 *************** *** 637,650 **** /* hash table for standard open hashing */ struct hashtable { /* HASHTABLE DATA */ int hsize; /* size of nodes[] (number of hash values) */ int ct; /* number of elements */ HashNode *nodes; /* array of size hsize */ - - #ifdef ZSH_HASH_DEBUG - char *tablename; /* string containing name of the hash table */ - #endif /* HASHTABLE METHODS */ HashFunc hash; /* pointer to hash function for this table */ --- 637,651 ---- /* hash table for standard open hashing */ struct hashtable { + #ifdef ZSH_HASH_DEBUG + HashTable next, last; /* linked list of all hash tables */ + char *tablename; /* string containing name of the hash table */ + #endif + /* HASHTABLE DATA */ int hsize; /* size of nodes[] (number of hash values) */ int ct; /* number of elements */ HashNode *nodes; /* array of size hsize */ /* HASHTABLE METHODS */ HashFunc hash; /* pointer to hash function for this table */ -----BEGIN PGP SIGNATURE----- Version: 2.6.2 iQCVAwUBMqDR4nD/+HJTpU/hAQGs5gQAuldI3pg+HbKDBXwOVYuBy1Nd0rrMlI9h 47B6s2qOTB0VKkILeSXEHc2pKi822DwQM426pVAfE8cOKG7gQucv8+87Dsj3BSfB 6Ih4Nzz/HlNIJrAncHqOYj2KNRnJ8tJJaP06HTHKwWua62VXomG8FJGGxUYNlJKS H38wbJWemWA= =Y8fs -----END PGP SIGNATURE-----