Module Name: othersrc Committed By: dholland Date: Sat Mar 23 18:27:18 UTC 2013
Modified Files: othersrc/usr.bin/dholland-make2: suff.c Log Message: Reorg some of the comments. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 othersrc/usr.bin/dholland-make2/suff.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: othersrc/usr.bin/dholland-make2/suff.c diff -u othersrc/usr.bin/dholland-make2/suff.c:1.16 othersrc/usr.bin/dholland-make2/suff.c:1.17 --- othersrc/usr.bin/dholland-make2/suff.c:1.16 Sat Mar 23 18:12:12 2013 +++ othersrc/usr.bin/dholland-make2/suff.c Sat Mar 23 18:27:18 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: suff.c,v 1.16 2013/03/23 18:12:12 dholland Exp $ */ +/* $NetBSD: suff.c,v 1.17 2013/03/23 18:27:18 dholland Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -131,7 +131,7 @@ #include "hash.h" #include "dir.h" -MAKE_RCSID("$NetBSD: suff.c,v 1.16 2013/03/23 18:12:12 dholland Exp $"); +MAKE_RCSID("$NetBSD: suff.c,v 1.17 2013/03/23 18:27:18 dholland Exp $"); #define CLEANUP @@ -229,22 +229,12 @@ static void SuffPrintName(Suff *); static void SuffPrintSuff(Suff *); static void SuffPrintTrans(GNode *); - /*************** Lst Predicates ****************/ -/*- - *----------------------------------------------------------------------- - * SuffStrIsPrefix -- - * See if pref is a prefix of str. - * - * Input: - * pref possible prefix - * str string to check - * - * Results: - * NULL if it ain't, pointer to character in str after prefix if so - * - * Side Effects: - * None - *----------------------------------------------------------------------- +//////////////////////////////////////////////////////////// +// support functions + +/* + * Check if PREF is a prefix of STR. If so, return the suffix part of + * STR. If not, return NULL. */ static const char * SuffStrIsPrefix(const char *pref, const char *str) @@ -258,8 +248,8 @@ SuffStrIsPrefix(const char *pref, const } /* - * Check if SUFF is a suffix of NAME. If so, return a pointer to - * the position of the suffix in NAME; otherwise, NULL. + * Check if SUFF is a suffix of NAME. If so, return a pointer to the + * position of the suffix in NAME; otherwise, NULL. */ static const char * SuffSuffIsSuffix(const Suff *suff, const char *name) @@ -280,20 +270,8 @@ SuffSuffIsSuffix(const Suff *suff, const return NULL; } -/*- - *----------------------------------------------------------------------- - * findtransform -- - * find an entry in transforms[] by name - * - * Input: - * name name of node we're looking for - * - * Results: - * the GNode, or NULL if it's not there - * - * Side Effects: - * None - *----------------------------------------------------------------------- +/* + * Find a GNode in transforms[] by name. Returns NULL if not there. */ static GNode * findtransform(const char *name) @@ -311,14 +289,18 @@ findtransform(const char *name) return NULL; } - /*********** Maintenance Functions ************/ - +/* + * Create a new reference to a suffix. + */ static void suff_incref(Suff *s) { s->refCount++; } +/* + * Drop a reference to a suffix. + */ static void suff_decref(Suff *s) { @@ -326,6 +308,10 @@ suff_decref(Suff *s) // XXX should destroy here but we need a cleanup pass first } +/* + * Remove a suffix from a suffix list and drop the associated + * reference. If not there, does nothing. + */ static void SuffUnRef(struct sufflist *l, Suff *s) { @@ -338,17 +324,8 @@ SuffUnRef(struct sufflist *l, Suff *s) } } -/*- - *----------------------------------------------------------------------- - * SuffFree -- - * Free up all memory associated with the given suffix structure. - * - * Results: - * none - * - * Side Effects: - * the suffix entry is detroyed - *----------------------------------------------------------------------- +/* + * Destroy a suffix. */ static void SuffFree(void *sp) @@ -383,18 +360,11 @@ SuffFree(void *sp) free(s); } -/*- - *----------------------------------------------------------------------- - * SuffRemove -- - * Remove the suffix into the list - * - * Results: - * None +/* + * Remove a suffix from a suffix list. Drop it from the master list + * too if it isn't referenced anywhere else (?). * - * Side Effects: - * The reference count for the suffix is decremented and the - * suffix is possibly freed - *----------------------------------------------------------------------- + * XXX: the refcount handling for suffixes is all hosed. */ static void SuffRemove(struct sufflist *l, Suff *s) @@ -405,23 +375,14 @@ SuffRemove(struct sufflist *l, Suff *s) SuffFree(s); } } - -/*- - *----------------------------------------------------------------------- - * SuffInsert -- - * Insert the suffix into the list keeping the list ordered by suffix - * numbers. - * - * Input: - * l the list where in s should be inserted - * s the suffix to insert + +/* + * Insert a suffix into a suffix list and create a reference for that. * - * Results: - * None + * Use sorted insert so the list stays ordered by suffix number. + * (XXX: surely we can do better than insertion sort...) * - * Side Effects: - * The reference count of the suffix is incremented - *----------------------------------------------------------------------- + * If the suffix is already present, do nothing. */ static void SuffInsert(struct sufflist *l, Suff *s) @@ -457,22 +418,17 @@ SuffInsert(struct sufflist *l, Suff *s) } } -/*- - *----------------------------------------------------------------------- - * Suff_ClearSuffixes -- - * This is gross. Nuke the list of suffixes but keep all transformation - * rules around. The transformation graph is destroyed in this process, - * but we leave the list of rules so when a new graph is formed the rules - * will remain. - * This function is called from the parse module when a - * .SUFFIXES:\n line is encountered. - * - * Results: - * none +//////////////////////////////////////////////////////////// +// real functions + +/* + * Forget all existing suffixes. This happens when an empty .SUFFIXES: + * line appears. * - * Side Effects: - * the sufflist and its graph nodes are destroyed - *----------------------------------------------------------------------- + * This is gross. Nuke the list of suffixes but keep all + * transformation rules around. The transformation graph is destroyed + * in this process, but we leave the list of rules so when a new graph + * is formed the rules will remain. */ void Suff_ClearSuffixes(void)