=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tsort/tsort.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- src/usr.bin/tsort/tsort.c 2002/02/17 19:42:33 1.13 +++ src/usr.bin/tsort/tsort.c 2002/02/27 20:26:37 1.14 @@ -1,4 +1,4 @@ -/* $OpenBSD: tsort.c,v 1.13 2002/02/17 19:42:33 millert Exp $ */ +/* $OpenBSD: tsort.c,v 1.14 2002/02/27 20:26:37 espie Exp $ */ /* ex:ts=8 sw=4: */ @@ -179,8 +179,7 @@ ***/ static void * -emem(p) - void *p; +emem(void *p) { if (p) return p; @@ -189,33 +188,25 @@ } static void * -hash_alloc(s, u) - size_t s; - void *u UNUSED; +hash_alloc(size_t s, void *u UNUSED) { return emem(calloc(s, 1)); } static void -hash_free(p, s, u) - void *p; - size_t s UNUSED; - void *u UNUSED; +hash_free(void *p, size_t s UNUSED, void *u UNUSED) { free(p); } static void * -entry_alloc(s, u) - size_t s; - void *u UNUSED; +entry_alloc(size_t s, void *u UNUSED) { return emalloc(s); } static void * -emalloc(s) - size_t s; +emalloc(size_t s) { return emem(malloc(s)); } @@ -228,9 +219,7 @@ /* Inserting and finding nodes in the hash structure. * We handle interval strings for efficiency wrt fgetln. */ static struct node * -new_node(start, end) - const char *start; - const char *end; +new_node(const char *start, const char *end) { struct node *n; @@ -246,17 +235,13 @@ static void -nodes_init(h) - struct ohash *h; +nodes_init(struct ohash *h) { ohash_init(h, HASH_START, &node_info); } static struct node * -node_lookup(h, start, end) - struct ohash *h; - const char *start; - const char *end; +node_lookup(struct ohash *h, const char *start, const char *end) { unsigned int i; struct node * n; @@ -271,8 +256,7 @@ #ifdef DEBUG static void -dump_node(n) - struct node *n; +dump_node(struct node *n) { struct link *l; @@ -286,8 +270,7 @@ } static void -dump_array(a) - struct array *a; +dump_array(struct array *a) { unsigned int i; @@ -296,8 +279,7 @@ } static void -dump_hash(h) - struct ohash *h; +dump_hash(struct ohash *h) { unsigned int i; struct node *n; @@ -313,8 +295,7 @@ ***/ static void -insert_arc(a, b) - struct node *a, *b; +insert_arc(struct node *a, struct node *b) { struct link *l; @@ -331,13 +312,8 @@ } static unsigned int -read_pairs(f, h, reverse, name, order, hint) - FILE *f; - struct ohash *h; - int reverse; - const char *name; - unsigned int order; - int hint; +read_pairs(FILE *f, struct ohash *h, int reverse, const char *name, + unsigned int order, int hint) { int toggle; struct node *a; @@ -388,12 +364,8 @@ } static unsigned int -read_hints(f, h, quiet, name, order) - FILE *f; - struct ohash *h; - int quiet; - const char *name; - unsigned int order; +read_hints(FILE *f, struct ohash *h, int quiet, const char *name, + unsigned int order) { char *str; size_t size; @@ -432,9 +404,7 @@ ***/ static void -heap_down(h, i) - struct array *h; - unsigned int i; +heap_down(struct array *h, unsigned int i) { unsigned int j; struct node *swap; @@ -451,9 +421,7 @@ } static void -heapify(h, verbose) - struct array *h; - int verbose; +heapify(struct array *h, int verbose) { unsigned int i; @@ -467,8 +435,7 @@ #define DEQUEUE(h) ( hints_flag ? dequeue(h) : (h)->t[--(h)->entries] ) static struct node * -dequeue(h) - struct array *h; +dequeue(struct array *h) { struct node *n; @@ -492,9 +459,7 @@ } while(0); static void -enqueue(h, n) - struct array *h; - struct node *n; +enqueue(struct array *h, struct node *n) { unsigned int i, j; struct node *swap; @@ -514,8 +479,7 @@ * Iterate until no nodes are left. */ static void -make_transparent(hash) - struct ohash *hash; +make_transparent(struct ohash *hash) { struct node *n; unsigned int i; @@ -571,10 +535,7 @@ /* Split nodes into unrefed nodes/live nodes. */ static void -split_nodes(hash, heap, remaining) - struct ohash *hash; - struct array *heap; - struct array *remaining; +split_nodes(struct ohash *hash, struct array *heap, struct array *remaining) { struct node *n; @@ -595,8 +556,7 @@ /* Good point to break a cycle: live node with as few refs as possible. */ static struct node * -find_good_cycle_break(h) - struct array *h; +find_good_cycle_break(struct array *h) { unsigned int i; unsigned int best; @@ -622,8 +582,7 @@ /* Retrieve the node with the smallest order. */ static struct node * -find_smallest_node(h) - struct array *h; +find_smallest_node(struct array *h) { unsigned int i; unsigned int best; @@ -652,9 +611,7 @@ /* Explore the nodes reachable from i to find a cycle, store it in c. * This may fail. */ static struct node * -find_cycle_from(i, c) - struct node *i; - struct array *c; +find_cycle_from(struct node *i, struct array *c) { struct node *n; @@ -702,9 +659,7 @@ * to go through the whole array, but it is not needed often. */ static struct node * -find_predecessor(a, n) - struct array *a; - struct node *n; +find_predecessor(struct array *a, struct node *n) { unsigned int i; @@ -729,10 +684,7 @@ Update the largest cycle found so far. */ static unsigned int -traverse_node(n, o, c) - struct node *n; - unsigned int o; - struct array *c; +traverse_node(struct node *n, unsigned int o, struct array *c) { unsigned int min, max; @@ -797,8 +749,7 @@ } static void -print_cycle(c) - struct array *c; +print_cycle(struct array *c) { unsigned int i; @@ -811,9 +762,7 @@ } static struct node * -find_longest_cycle(h, c) - struct array *h; - struct array *c; +find_longest_cycle(struct array *h, struct array *c) { unsigned int i; unsigned int o; @@ -863,9 +812,7 @@ #define plural(n) ((n) > 1 ? "s" : "") int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { struct ohash pairs; int reverse_flag, quiet_flag, long_flag,