Ignore:
Timestamp:
Nov 26, 2002, 10:24:54 PM (23 years ago)
Author:
bird
Message:

Import of RELENG_4_7_0_RELEASE

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/FREEBSD/src/kmk/targ.c

    r10 r24  
    3535 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    3636 * SUCH DAMAGE.
    37  *
    38  * @(#)targ.c   8.2 (Berkeley) 3/19/94
    39  */
    40 
    41 #include <sys/cdefs.h>
    42 __FBSDID("$FreeBSD: src/usr.bin/make/targ.c,v 1.25 2002/10/09 03:42:10 jmallett Exp $");
     37 */
     38
     39#ifndef lint
     40#if 0
     41static char sccsid[] = "@(#)targ.c      8.2 (Berkeley) 3/19/94";
     42#else
     43static const char rcsid[] =
     44  "$FreeBSD: src/usr.bin/make/targ.c,v 1.10 1999/09/11 13:08:02 hoek Exp $";
     45#endif
     46#endif /* not lint */
    4347
    4448/*-
     
    9397static Hash_Table targets;      /* a hash table of same */
    9498
    95 #define HTSIZE  191             /* initial size of hash table */
    96 
    97 static int TargPrintOnlySrc(void *, void *);
    98 static int TargPrintName(void *, void *);
    99 static int TargPrintNode(void *, void *);
    100 static void TargFreeGN(void *);
     99#define HTSIZE  191             /* initial size of hash table */
     100
     101static int TargPrintOnlySrc __P((ClientData, ClientData));
     102static int TargPrintName __P((ClientData, ClientData));
     103static int TargPrintNode __P((ClientData, ClientData));
     104static void TargFreeGN __P((ClientData));
    101105
    102106/*-
     
    113117 */
    114118void
    115 Targ_Init (void)
     119Targ_Init ()
    116120{
    117121    allTargets = Lst_Init (FALSE);
     
    132136 */
    133137void
    134 Targ_End (void)
     138Targ_End ()
    135139{
    136140    Lst_Destroy(allTargets, NOFREE);
     
    154158 */
    155159GNode *
    156 Targ_NewGN (char *name)
    157 {
    158     GNode *gn;
     160Targ_NewGN (name)
     161    char           *name;       /* the name to stick in the new node */
     162{
     163    register GNode *gn;
    159164
    160165    gn = (GNode *) emalloc (sizeof (GNode));
     
    184189    if (allGNs == NULL)
    185190        allGNs = Lst_Init(FALSE);
    186     Lst_AtEnd(allGNs, (void *) gn);
     191    Lst_AtEnd(allGNs, (ClientData) gn);
    187192
    188193    return (gn);
     
    202207 */
    203208static void
    204 TargFreeGN (void *gnp)
     209TargFreeGN (gnp)
     210    ClientData gnp;
    205211{
    206212    GNode *gn = (GNode *) gnp;
     
    218224    Lst_Destroy(gn->context, NOFREE);
    219225    Lst_Destroy(gn->commands, NOFREE);
    220     free(gn);
     226    free((Address)gn);
    221227}
    222228
     
    228234 *
    229235 * Results:
    230  *      The node in the list if it was. If it wasn't, return NULL of
     236 *      The node in the list if it was. If it wasn't, return NILGNODE of
    231237 *      flags was TARG_NOCREATE or the newly created and initialized node
    232238 *      if it was TARG_CREATE
     
    237243 */
    238244GNode *
    239 Targ_FindNode (char *name, int flags)
     245Targ_FindNode (name, flags)
     246    char           *name;       /* the name to find */
     247    int             flags;      /* flags governing events when target not
     248                                 * found */
    240249{
    241250    GNode         *gn;        /* node in that element */
     
    250259            gn = Targ_NewGN (name);
    251260            Hash_SetValue (he, gn);
    252             (void) Lst_AtEnd (allTargets, (void *)gn);
     261            (void) Lst_AtEnd (allTargets, (ClientData)gn);
    253262        }
    254263    } else {
     
    257266
    258267    if (he == (Hash_Entry *) NULL) {
    259         return (NULL);
     268        return (NILGNODE);
    260269    } else {
    261270        return ((GNode *) Hash_GetValue (he));
     
    279288 */
    280289Lst
    281 Targ_FindList (Lst names, int flags)
     290Targ_FindList (names, flags)
     291    Lst            names;       /* list of names to find */
     292    int            flags;       /* flags used if no node is found for a given
     293                                 * name */
    282294{
    283295    Lst            nodes;       /* result list */
    284     LstNode        ln;          /* name list element */
    285     GNode          *gn;         /* node in tLn */
    286     char           *name;
     296    register LstNode  ln;               /* name list element */
     297    register GNode *gn;         /* node in tLn */
     298    char          *name;
    287299
    288300    nodes = Lst_Init (FALSE);
     
    291303        return (nodes);
    292304    }
    293     while ((ln = Lst_Next (names)) != NULL) {
     305    while ((ln = Lst_Next (names)) != NILLNODE) {
    294306        name = (char *)Lst_Datum(ln);
    295307        gn = Targ_FindNode (name, flags);
    296         if (gn != NULL) {
     308        if (gn != NILGNODE) {
    297309            /*
    298310             * Note: Lst_AtEnd must come before the Lst_Concat so the nodes
     
    300312             * encountered in the makefile.
    301313             */
    302             (void) Lst_AtEnd (nodes, (void *)gn);
     314            (void) Lst_AtEnd (nodes, (ClientData)gn);
    303315            if (gn->type & OP_DOUBLEDEP) {
    304316                (void)Lst_Concat (nodes, gn->cohorts, LST_CONCNEW);
     
    325337 */
    326338Boolean
    327 Targ_Ignore (GNode *gn)
     339Targ_Ignore (gn)
     340    GNode          *gn;         /* node to check for */
    328341{
    329342    if (ignoreErrors || gn->type & OP_IGNORE) {
     
    347360 */
    348361Boolean
    349 Targ_Silent (GNode *gn)
     362Targ_Silent (gn)
     363    GNode          *gn;         /* node to check for */
    350364{
    351365    if (beSilent || gn->type & OP_SILENT) {
     
    369383 */
    370384Boolean
    371 Targ_Precious (GNode *gn)
     385Targ_Precious (gn)
     386    GNode          *gn;         /* the node to check */
    372387{
    373388    if (allPrecious || (gn->type & (OP_PRECIOUS|OP_DOUBLEDEP))) {
     
    395410 */
    396411void
    397 Targ_SetMain (GNode *gn)
     412Targ_SetMain (gn)
     413    GNode   *gn;        /* The main target we'll create */
    398414{
    399415    mainTarg = gn;
     
    401417
    402418static int
    403 TargPrintName (void *gnp, void *ppath)
     419TargPrintName (gnp, ppath)
     420    ClientData     gnp;
     421    ClientData      ppath;
    404422{
    405423    GNode *gn = (GNode *) gnp;
     
    420438
    421439int
    422 Targ_PrintCmd (void *cmd, void *dummy __unused)
     440Targ_PrintCmd (cmd, dummy)
     441    ClientData cmd;
     442    ClientData dummy;
    423443{
    424444    printf ("\t%s\n", (char *) cmd);
    425     return (0);
     445    return (dummy ? 0 : 0);
    426446}
    427447
     
    441461 */
    442462char *
    443 Targ_FmtTime (time_t modtime)
     463Targ_FmtTime (time)
     464    time_t    time;
    444465{
    445466    struct tm           *parts;
    446467    static char         buf[128];
    447468
    448     parts = localtime(&modtime);
    449 
    450     strftime(buf, sizeof buf, "%H:%M:%S %b %d, %Y", parts);
     469    parts = localtime(&time);
     470
     471    strftime(buf, sizeof buf, "%k:%M:%S %b %d, %Y", parts);
    451472    buf[sizeof(buf) - 1] = '\0';
    452473    return(buf);
     
    466487 */
    467488void
    468 Targ_PrintType (int type)
    469 {
    470     int    tbit;
    471 
    472 #define PRINTBIT(attr)  case CONCAT(OP_,attr): printf("." #attr " "); break
    473 #define PRINTDBIT(attr) case CONCAT(OP_,attr): DEBUGF(TARG, ("." #attr " ")); break
     489Targ_PrintType (type)
     490    register int    type;
     491{
     492    register int    tbit;
     493
     494#ifdef __STDC__
     495#define PRINTBIT(attr)  case CONCAT(OP_,attr): printf("." #attr " "); break
     496#define PRINTDBIT(attr) case CONCAT(OP_,attr): if (DEBUG(TARG)) printf("." #attr " "); break
     497#else
     498#define PRINTBIT(attr)  case CONCAT(OP_,attr): printf(".attr "); break
     499#define PRINTDBIT(attr) case CONCAT(OP_,attr): if (DEBUG(TARG)) printf(".attr "); break
     500#endif /* __STDC__ */
    474501
    475502    type &= ~OP_OPMASK;
     
    492519            PRINTDBIT(LIB);
    493520            /*XXX: MEMBER is defined, so CONCAT(OP_,MEMBER) gives OP_"%" */
    494             case OP_MEMBER: DEBUGF(TARG, (".MEMBER ")); break;
     521            case OP_MEMBER: if (DEBUG(TARG)) printf(".MEMBER "); break;
    495522            PRINTDBIT(ARCHV);
    496523        }
     
    505532 */
    506533static int
    507 TargPrintNode (void *gnp, void *passp)
     534TargPrintNode (gnp, passp)
     535    ClientData   gnp;
     536    ClientData   passp;
    508537{
    509538    GNode         *gn = (GNode *) gnp;
     
    540569            if (!Lst_IsEmpty (gn->iParents)) {
    541570                printf("# implicit parents: ");
    542                 Lst_ForEach (gn->iParents, TargPrintName, (void *)0);
     571                Lst_ForEach (gn->iParents, TargPrintName, (ClientData)0);
    543572                fputc ('\n', stdout);
    544573            }
     
    546575        if (!Lst_IsEmpty (gn->parents)) {
    547576            printf("# parents: ");
    548             Lst_ForEach (gn->parents, TargPrintName, (void *)0);
     577            Lst_ForEach (gn->parents, TargPrintName, (ClientData)0);
    549578            fputc ('\n', stdout);
    550579        }
     
    558587            case OP_DOUBLEDEP:
    559588                printf(":: "); break;
    560             default:
    561                 break;
    562589        }
    563590        Targ_PrintType (gn->type);
    564         Lst_ForEach (gn->children, TargPrintName, (void *)0);
     591        Lst_ForEach (gn->children, TargPrintName, (ClientData)0);
    565592        fputc ('\n', stdout);
    566         Lst_ForEach (gn->commands, Targ_PrintCmd, (void *)0);
     593        Lst_ForEach (gn->commands, Targ_PrintCmd, (ClientData)0);
    567594        printf("\n\n");
    568595        if (gn->type & OP_DOUBLEDEP) {
    569             Lst_ForEach (gn->cohorts, TargPrintNode, (void *)&pass);
     596            Lst_ForEach (gn->cohorts, TargPrintNode, (ClientData)&pass);
    570597        }
    571598    }
     
    582609 *
    583610 * Side Effects:
    584  *      The name of each file is printed preceded by #\t
     611 *      The name of each file is printed preceeded by #\t
    585612 *
    586613 *-----------------------------------------------------------------------
    587614 */
    588615static int
    589 TargPrintOnlySrc(void *gnp, void *dummy __unused)
     616TargPrintOnlySrc(gnp, dummy)
     617    ClientData    gnp;
     618    ClientData    dummy;
    590619{
    591620    GNode         *gn = (GNode *) gnp;
     
    593622        printf("#\t%s [%s]\n", gn->name, gn->path ? gn->path : gn->name);
    594623
    595     return (0);
     624    return (dummy ? 0 : 0);
    596625}
    597626
     
    599628 *-----------------------------------------------------------------------
    600629 * Targ_PrintGraph --
    601  *      Print the entire graph.
     630 *      print the entire graph. heh heh
    602631 *
    603632 * Results:
     
    609638 */
    610639void
    611 Targ_PrintGraph (int pass)
     640Targ_PrintGraph (pass)
     641    int     pass;       /* Which pass this is. 1 => no processing
     642                         * 2 => processing done */
    612643{
    613644    printf("#*** Input graph:\n");
    614     Lst_ForEach (allTargets, TargPrintNode, (void *)&pass);
     645    Lst_ForEach (allTargets, TargPrintNode, (ClientData)&pass);
    615646    printf("\n\n");
    616647    printf("#\n#   Files that are only sources:\n");
    617     Lst_ForEach (allTargets, TargPrintOnlySrc, (void *) 0);
     648    Lst_ForEach (allTargets, TargPrintOnlySrc, (ClientData) 0);
    618649    printf("#*** Global Variables:\n");
    619650    Var_Dump (VAR_GLOBAL);
Note: See TracChangeset for help on using the changeset viewer.