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/for.c

    r10 r24  
    11/*
    2  * Copyright (c) 1993
    3  *      The Regents of the University of California.  All rights reserved.
    4  *
    5  * This code is derived from software contributed to Berkeley by
    6  * Christos Zoulas.
     2 * Copyright (c) 1992, The Regents of the University of California.
     3 * All rights reserved.
    74 *
    85 * Redistribution and use in source and binary forms, with or without
     
    3330 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    3431 * SUCH DAMAGE.
    35  *
    36  * @(#)for.c    8.1 (Berkeley) 6/6/93
    37  */
    38 
    39 #include <sys/cdefs.h>
    40 __FBSDID("$FreeBSD: src/usr.bin/make/for.c,v 1.19 2002/10/09 03:42:10 jmallett Exp $");
     32 */
     33
     34#ifndef lint
     35#if 0
     36static char sccsid[] = "@(#)for.c       8.1 (Berkeley) 6/6/93";
     37#else
     38static const char rcsid[] =
     39  "$FreeBSD: src/usr.bin/make/for.c,v 1.10 1999/09/11 13:08:01 hoek Exp $";
     40#endif
     41#endif /* not lint */
    4142
    4243/*-
     
    8485} For;
    8586
    86 static int ForExec(void *, void *);
     87static int ForExec      __P((ClientData, ClientData));
    8788
    8889
     
    108109 */
    109110int
    110 For_Eval (char *line)
     111For_Eval (line)
     112    char            *line;    /* Line to parse */
    111113{
    112114    char            *ptr = line, *sub, *wrd;
     
    176178        sub = Var_Subst(NULL, ptr, VAR_GLOBAL, FALSE);
    177179
    178 #define ADDWORD() \
     180#define ADDWORD() \
    179181        Buf_AddBytes(buf, ptr - wrd, (Byte *) wrd), \
    180182        Buf_AddByte(buf, (Byte) '\0'), \
    181         Lst_AtFront(forLst, (void *) Buf_GetAll(buf, &varlen)), \
     183        Lst_AtFront(forLst, (ClientData) Buf_GetAll(buf, &varlen)), \
    182184        Buf_Destroy(buf, FALSE)
    183185
     
    193195                wrd = ptr--;
    194196            }
    195         DEBUGF(FOR, ("For: Iterator %s List %s\n", forVar, sub));
     197        if (DEBUG(FOR))
     198            (void) fprintf(stderr, "For: Iterator %s List %s\n", forVar, sub);
    196199        if (ptr - wrd > 0)
    197200            ADDWORD();
    198201        else
    199202            Buf_Destroy(buf, TRUE);
    200         free(sub);
     203        free((Address) sub);
    201204
    202205        forBuf = Buf_Init(0);
     
    211214        if (strncmp(ptr, "endfor", 6) == 0 &&
    212215            (isspace((unsigned char) ptr[6]) || !ptr[6])) {
    213             DEBUGF(FOR, ("For: end for %d\n", forLevel));
     216            if (DEBUG(FOR))
     217                (void) fprintf(stderr, "For: end for %d\n", forLevel);
    214218            if (--forLevel < 0) {
    215219                Parse_Error (level, "for-less endfor");
     
    220224                 isspace((unsigned char) ptr[3])) {
    221225            forLevel++;
    222             DEBUGF(FOR, ("For: new loop %d\n", forLevel));
     226            if (DEBUG(FOR))
     227                (void) fprintf(stderr, "For: new loop %d\n", forLevel);
    223228        }
    224229    }
     
    248253 */
    249254static int
    250 ForExec(void *namep, void *argp)
     255ForExec(namep, argp)
     256    ClientData namep;
     257    ClientData argp;
    251258{
    252259    char *name = (char *) namep;
     
    254261    int len;
    255262    Var_Set(arg->var, name, VAR_GLOBAL);
    256     DEBUGF(FOR, ("--- %s = %s\n", arg->var, name));
     263    if (DEBUG(FOR))
     264        (void) fprintf(stderr, "--- %s = %s\n", arg->var, name);
    257265    Parse_FromString(Var_Subst(arg->var, (char *) Buf_GetAll(arg->buf, &len),
    258266                               VAR_GLOBAL, FALSE));
     
    278286 */
    279287void
    280 For_Run(void)
     288For_Run()
    281289{
    282290    For arg;
     
    291299    forLst = NULL;
    292300
    293     Lst_ForEach(arg.lst, ForExec, (void *) &arg);
    294 
    295     free(arg.var);
    296     Lst_Destroy(arg.lst, (void (*)(void *)) free);
     301    Lst_ForEach(arg.lst, ForExec, (ClientData) &arg);
     302
     303    free((Address)arg.var);
     304    Lst_Destroy(arg.lst, (void (*) __P((ClientData))) free);
    297305    Buf_Destroy(arg.buf, TRUE);
    298306}
Note: See TracChangeset for help on using the changeset viewer.