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

    r10 r24  
    3535 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    3636 * SUCH DAMAGE.
    37  *
    38  * @(#)parse.c  8.3 (Berkeley) 3/19/94
    39  */
    40 
    41 #include <sys/cdefs.h>
    42 __FBSDID("$FreeBSD: src/usr.bin/make/parse.c,v 1.48 2002/10/09 03:42:10 jmallett Exp $");
     37 */
     38
     39#ifndef lint
     40#if 0
     41static char sccsid[] = "@(#)parse.c     8.3 (Berkeley) 3/19/94";
     42#else
     43static const char rcsid[] =
     44  "$FreeBSD: src/usr.bin/make/parse.c,v 1.22 1999/08/28 01:03:35 peter Exp $";
     45#endif
     46#endif /* not lint */
    4347
    4448/*-
     
    8488 */
    8589
     90#ifdef __STDC__
    8691#include <stdarg.h>
     92#else
     93#include <varargs.h>
     94#endif
    8795#include <ctype.h>
    8896#include <err.h>
     
    178186
    179187/*
    180  * Predecessor node for handling .ORDER. Initialized to NULL when .ORDER
     188 * Predecessor node for handling .ORDER. Initialized to NILGNODE when .ORDER
    181189 * seen, then set to each successive source on the line.
    182190 */
     
    231239};
    232240
    233 static int ParseFindKeyword(char *);
    234 static int ParseLinkSrc(void *, void *);
    235 static int ParseDoOp(void *, void *);
    236 static int ParseAddDep(void *, void *);
    237 static void ParseDoSrc(int, char *, Lst);
    238 static int ParseFindMain(void *, void *);
    239 static int ParseAddDir(void *, void *);
    240 static int ParseClearPath(void *, void *);
    241 static void ParseDoDependency(char *);
    242 static int ParseAddCmd(void *, void *);
    243 static int ParseReadc(void);
    244 static void ParseUnreadc(int);
    245 static void ParseHasCommands(void *);
    246 static void ParseDoInclude(char *);
    247 static void ParseDoError(char *);
     241static int ParseFindKeyword __P((char *));
     242static int ParseLinkSrc __P((ClientData, ClientData));
     243static int ParseDoOp __P((ClientData, ClientData));
     244static int ParseAddDep __P((ClientData, ClientData));
     245static void ParseDoSrc __P((int, char *, Lst));
     246static int ParseFindMain __P((ClientData, ClientData));
     247static int ParseAddDir __P((ClientData, ClientData));
     248static int ParseClearPath __P((ClientData, ClientData));
     249static void ParseDoDependency __P((char *));
     250static int ParseAddCmd __P((ClientData, ClientData));
     251static int ParseReadc __P((void));
     252static void ParseUnreadc __P((int));
     253static void ParseHasCommands __P((ClientData));
     254static void ParseDoInclude __P((char *));
     255static void ParseDoError __P((char *));
    248256#ifdef SYSVINCLUDE
    249 static void ParseTraditionalInclude(char *);
     257static void ParseTraditionalInclude __P((char *));
    250258#endif
    251 static int ParseEOF(int);
    252 static char *ParseReadLine(void);
    253 static char *ParseSkipLine(int);
    254 static void ParseFinishLine(void);
     259static int ParseEOF __P((int));
     260static char *ParseReadLine __P((void));
     261static char *ParseSkipLine __P((int));
     262static void ParseFinishLine __P((void));
    255263
    256264/*-
     
    267275 */
    268276static int
    269 ParseFindKeyword (char *str)
    270 {
    271     int             start,
     277ParseFindKeyword (str)
     278    char            *str;               /* String to find */
     279{
     280    register int    start,
    272281                    end,
    273282                    cur;
    274     int             diff;
     283    register int    diff;
    275284
    276285    start = 0;
     
    306315/* VARARGS */
    307316void
    308 Parse_Error(int type, const char *fmt, ...)
     317#ifdef __STDC__
     318Parse_Error(int type, char *fmt, ...)
     319#else
     320Parse_Error(va_alist)
     321        va_dcl
     322#endif
    309323{
    310324        va_list ap;
    311 
     325#ifdef __STDC__
    312326        va_start(ap, fmt);
     327#else
     328        int type;               /* Error type (PARSE_WARNING, PARSE_FATAL) */
     329        char *fmt;
     330
     331        va_start(ap);
     332        type = va_arg(ap, int);
     333        fmt = va_arg(ap, char *);
     334#endif
     335
    313336        (void)fprintf(stderr, "\"%s\", line %d: ", fname, lineno);
    314337        if (type == PARSE_WARNING)
     
    339362 */
    340363static int
    341 ParseLinkSrc (void *pgnp, void *cgnp)
     364ParseLinkSrc (pgnp, cgnp)
     365    ClientData     pgnp;        /* The parent node */
     366    ClientData     cgnp;        /* The child node */
    342367{
    343368    GNode          *pgn = (GNode *) pgnp;
    344369    GNode          *cgn = (GNode *) cgnp;
    345     if (Lst_Member (pgn->children, (void *)cgn) == NULL) {
    346         (void)Lst_AtEnd (pgn->children, (void *)cgn);
     370    if (Lst_Member (pgn->children, (ClientData)cgn) == NILLNODE) {
     371        (void)Lst_AtEnd (pgn->children, (ClientData)cgn);
    347372        if (specType == Not) {
    348             (void)Lst_AtEnd (cgn->parents, (void *)pgn);
     373            (void)Lst_AtEnd (cgn->parents, (ClientData)pgn);
    349374        }
    350375        pgn->unmade += 1;
     
    370395 */
    371396static int
    372 ParseDoOp (void *gnp, void *opp)
     397ParseDoOp (gnp, opp)
     398    ClientData     gnp;         /* The node to which the operator is to be
     399                                 * applied */
     400    ClientData     opp;         /* The operator to apply */
    373401{
    374402    GNode          *gn = (GNode *) gnp;
     
    395423         * instance.
    396424         */
    397         GNode           *cohort;
     425        register GNode  *cohort;
    398426        LstNode         ln;
    399427
     
    408436         * sorry.
    409437         */
    410         Lst_ForEach(gn->parents, ParseLinkSrc, (void *)cohort);
     438        Lst_ForEach(gn->parents, ParseLinkSrc, (ClientData)cohort);
    411439        cohort->type = OP_DOUBLEDEP|OP_INVISIBLE;
    412         (void)Lst_AtEnd(gn->cohorts, (void *)cohort);
     440        (void)Lst_AtEnd(gn->cohorts, (ClientData)cohort);
    413441
    414442        /*
    415443         * Replace the node in the targets list with the new copy
    416444         */
    417         ln = Lst_Member(targets, (void *)gn);
    418         Lst_Replace(ln, (void *)cohort);
     445        ln = Lst_Member(targets, (ClientData)gn);
     446        Lst_Replace(ln, (ClientData)cohort);
    419447        gn = cohort;
    420448    }
     
    445473 */
    446474static int
    447 ParseAddDep(void *pp, void *sp)
     475ParseAddDep(pp, sp)
     476    ClientData pp;
     477    ClientData sp;
    448478{
    449479    GNode *p = (GNode *) pp;
     
    456486         * problem
    457487         */
    458         (void)Lst_AtEnd(p->successors, (void *)s);
    459         (void)Lst_AtEnd(s->preds, (void *)p);
     488        (void)Lst_AtEnd(p->successors, (ClientData)s);
     489        (void)Lst_AtEnd(s->preds, (ClientData)p);
    460490        return 0;
    461491    }
     
    483513 */
    484514static void
    485 ParseDoSrc (int tOp, char *src, Lst allsrc)
     515ParseDoSrc (tOp, src, allsrc)
     516    int         tOp;    /* operator (if any) from special targets */
     517    char        *src;   /* name of the source to handle */
     518    Lst         allsrc; /* List of all sources to wait for */
    486519{
    487520    GNode       *gn = NULL;
    488521
    489     if (*src == '.' && isupper ((unsigned char) src[1])) {
     522    if (*src == '.' && isupper (src[1])) {
    490523        int keywd = ParseFindKeyword(src);
    491524        if (keywd != -1) {
    492525            int op = parseKeywords[keywd].op;
    493526            if (op != 0) {
    494                 Lst_ForEach (targets, ParseDoOp, (void *)&op);
     527                Lst_ForEach (targets, ParseDoOp, (ClientData)&op);
    495528                return;
    496529            }
     
    512545         * line. This is to allow #ifmake's to succeed, or something...
    513546         */
    514         (void) Lst_AtEnd (create, (void *)estrdup(src));
     547        (void) Lst_AtEnd (create, (ClientData)estrdup(src));
    515548        /*
    516549         * Add the name to the .TARGETS variable as well, so the user cna
     
    526559         */
    527560        gn = Targ_FindNode(src, TARG_CREATE);
    528         if (predecessor != NULL) {
    529             (void)Lst_AtEnd(predecessor->successors, (void *)gn);
    530             (void)Lst_AtEnd(gn->preds, (void *)predecessor);
     561        if (predecessor != NILGNODE) {
     562            (void)Lst_AtEnd(predecessor->successors, (ClientData)gn);
     563            (void)Lst_AtEnd(gn->preds, (ClientData)predecessor);
    531564        }
    532565        /*
     
    552585            gn->type |= tOp;
    553586        } else {
    554             Lst_ForEach (targets, ParseLinkSrc, (void *)gn);
     587            Lst_ForEach (targets, ParseLinkSrc, (ClientData)gn);
    555588        }
    556589        if ((gn->type & OP_OPMASK) == OP_DOUBLEDEP) {
    557             GNode       *cohort;
    558             LstNode     ln;
    559 
    560             for (ln=Lst_First(gn->cohorts); ln != NULL; ln = Lst_Succ(ln)){
     590            register GNode      *cohort;
     591            register LstNode    ln;
     592
     593            for (ln=Lst_First(gn->cohorts); ln != NILLNODE; ln = Lst_Succ(ln)){
    561594                cohort = (GNode *)Lst_Datum(ln);
    562595                if (tOp) {
    563596                    cohort->type |= tOp;
    564597                } else {
    565                     Lst_ForEach(targets, ParseLinkSrc, (void *)cohort);
     598                    Lst_ForEach(targets, ParseLinkSrc, (ClientData)cohort);
    566599                }
    567600            }
     
    571604
    572605    gn->order = waiting;
    573     (void)Lst_AtEnd(allsrc, (void *)gn);
     606    (void)Lst_AtEnd(allsrc, (ClientData)gn);
    574607    if (waiting) {
    575         Lst_ForEach(allsrc, ParseAddDep, (void *)gn);
     608        Lst_ForEach(allsrc, ParseAddDep, (ClientData)gn);
    576609    }
    577610}
     
    593626 */
    594627static int
    595 ParseFindMain(void *gnp, void *dummy __unused)
     628ParseFindMain(gnp, dummy)
     629    ClientData    gnp;      /* Node to examine */
     630    ClientData    dummy;
    596631{
    597632    GNode         *gn = (GNode *) gnp;
     
    599634        mainNode = gn;
    600635        Targ_SetMain(gn);
    601         return (1);
     636        return (dummy ? 1 : 1);
    602637    } else {
    603         return (0);
     638        return (dummy ? 0 : 0);
    604639    }
    605640}
     
    619654 */
    620655static int
    621 ParseAddDir(void *path, void *name)
     656ParseAddDir(path, name)
     657    ClientData    path;
     658    ClientData    name;
    622659{
    623660    Dir_AddDir((Lst) path, (char *) name);
     
    639676 */
    640677static int
    641 ParseClearPath(void *path, void *dummy __unused)
     678ParseClearPath(path, dummy)
     679    ClientData path;
     680    ClientData dummy;
    642681{
    643682    Dir_ClearPath((Lst) path);
    644     return (0);
     683    return(dummy ? 0 : 0);
    645684}
    646685
     
    680719 */
    681720static void
    682 ParseDoDependency (char *line)
     721ParseDoDependency (line)
     722    char           *line;       /* the line to parse */
    683723{
    684724    char           *cp;         /* our current position */
     
    706746    do {
    707747        for (cp = line;
    708              *cp && !isspace ((unsigned char) *cp) && *cp != '(';
     748             *cp && !isspace (*cp) &&
     749             (*cp != '!') && (*cp != ':') && (*cp != '(');
    709750             cp++)
    710751        {
     
    727768                }
    728769                cp += length-1;
    729             } else if (*cp == '!' || *cp == ':') {
    730                 /*
    731                  * We don't want to end a word on ':' or '!' if there is a
    732                  * better match later on in the string.  By "better" I mean
    733                  * one that is followed by whitespace.  This allows the user
    734                  * to have targets like:
    735                  *    fie::fi:fo: fum
    736                  * where "fie::fi:fo" is the target.  In real life this is used
    737                  * for perl5 library man pages where "::" separates an object
    738                  * from its class.  Ie: "File::Spec::Unix".  This behaviour
    739                  * is also consistent with other versions of make.
    740                  */
    741                 char *p = cp + 1;
    742 
    743                 if (*cp == ':' && *p == ':')
    744                     p++;
    745 
    746                 /* Found the best match already. */
    747                 if (*p == '\0' || isspace(*p))
    748                     break;
    749 
    750                 do {
    751                     p += strcspn(p, "!:");
    752                     if (*p == '\0')
    753                         break;
    754                 } while (!isspace(*++p));
    755 
    756                 /* No better match later on... */
    757                 if (*p == '\0')
    758                     break;
    759770            }
    760771            continue;
     
    784795            /*
    785796             * Ending a dependency line without an operator is a Bozo
    786              * no-no.  As a heuristic, this is also often triggered by
    787              * undetected conflicts from cvs/rcs merges.
     797             * no-no
    788798             */
    789             if ((strncmp(line, "<<<<<<", 6) == 0) ||
    790                 (strncmp(line, "======", 6) == 0) ||
    791                 (strncmp(line, ">>>>>>", 6) == 0))
    792                 Parse_Error (PARSE_FATAL,
    793                     "Makefile appears to contain unresolved cvs/rcs/??? merge conflicts");
    794             else
    795                 Parse_Error (PARSE_FATAL, "Need an operator");
     799            Parse_Error (PARSE_FATAL, "Need an operator");
    796800            return;
    797801        }
     
    801805         * specType to match it.
    802806         */
    803         if (*line == '.' && isupper ((unsigned char) line[1])) {
     807        if (*line == '.' && isupper (line[1])) {
    804808            /*
    805809             * See if the target is a special target that must have it
     
    842846                 *      .NOTPARALLEL    Make only one target at a time.
    843847                 *      .SINGLESHELL    Create a shell for each command.
    844                  *      .ORDER          Must set initial predecessor to NULL
     848                 *      .ORDER          Must set initial predecessor to NIL
    845849                 */
    846850                switch (specType) {
     
    849853                            paths = Lst_Init(FALSE);
    850854                        }
    851                         (void)Lst_AtEnd(paths, (void *)dirSearchPath);
     855                        (void)Lst_AtEnd(paths, (ClientData)dirSearchPath);
    852856                        break;
    853857                    case Main:
     
    861865                        gn = Targ_FindNode(line, TARG_CREATE);
    862866                        gn->type |= OP_NOTMAIN;
    863                         (void)Lst_AtEnd(targets, (void *)gn);
     867                        (void)Lst_AtEnd(targets, (ClientData)gn);
    864868                        break;
    865869                    case Default:
    866870                        gn = Targ_NewGN(".DEFAULT");
    867871                        gn->type |= (OP_NOTMAIN|OP_TRANSFORM);
    868                         (void)Lst_AtEnd(targets, (void *)gn);
     872                        (void)Lst_AtEnd(targets, (ClientData)gn);
    869873                        DEFAULT = gn;
    870874                        break;
    871875                    case NotParallel:
    872876                    {
     877                        extern int  maxJobs;
     878
    873879                        maxJobs = 1;
    874880                        break;
     
    878884                        break;
    879885                    case Order:
    880                         predecessor = NULL;
     886                        predecessor = NILGNODE;
    881887                        break;
    882888                    default:
     
    893899                specType = ExPath;
    894900                path = Suff_GetPath (&line[5]);
    895                 if (path == NULL) {
     901                if (path == NILLST) {
    896902                    Parse_Error (PARSE_FATAL,
    897903                                 "Suffix '%s' not defined (yet)",
     
    902908                        paths = Lst_Init(FALSE);
    903909                    }
    904                     (void)Lst_AtEnd(paths, (void *)path);
     910                    (void)Lst_AtEnd(paths, (ClientData)path);
    905911                }
    906912            }
     
    929935                 * so create a list with the word on it.
    930936                 */
    931                 (void)Lst_AtEnd(curTargs, (void *)line);
     937                (void)Lst_AtEnd(curTargs, (ClientData)line);
    932938            }
    933939
     
    941947                }
    942948
    943                 (void)Lst_AtEnd (targets, (void *)gn);
     949                (void)Lst_AtEnd (targets, (ClientData)gn);
    944950            }
    945951        } else if (specType == ExPath && *line != '.' && *line != '\0') {
     
    965971            }
    966972        } else {
    967             while (*cp && isspace ((unsigned char) *cp)) {
     973            while (*cp && isspace (*cp)) {
    968974                cp++;
    969975            }
     
    10181024    cp++;                       /* Advance beyond operator */
    10191025
    1020     Lst_ForEach (targets, ParseDoOp, (void *)&op);
     1026    Lst_ForEach (targets, ParseDoOp, (ClientData)&op);
    10211027
    10221028    /*
    10231029     * Get to the first source
    10241030     */
    1025     while (*cp && isspace ((unsigned char) *cp)) {
     1031    while (*cp && isspace (*cp)) {
    10261032        cp++;
    10271033    }
     
    10521058                break;
    10531059            case ExPath:
    1054                 Lst_ForEach(paths, ParseClearPath, (void *)NULL);
     1060                Lst_ForEach(paths, ParseClearPath, (ClientData)NULL);
    10551061                break;
    10561062#ifdef POSIX
     
    11121118             * has no valid suffix.
    11131119             */
    1114             char  savech;
    1115             while (*cp && !isspace ((unsigned char) *cp)) {
     1120            char  savec;
     1121            while (*cp && !isspace (*cp)) {
    11161122                cp++;
    11171123            }
    1118             savech = *cp;
     1124            savec = *cp;
    11191125            *cp = '\0';
    11201126            switch (specType) {
     
    11231129                    break;
    11241130                case ExPath:
    1125                     Lst_ForEach(paths, ParseAddDir, (void *)line);
     1131                    Lst_ForEach(paths, ParseAddDir, (ClientData)line);
    11261132                    break;
    11271133                case Includes:
     
    11371143                    break;
    11381144            }
    1139             *cp = savech;
    1140             if (savech != '\0') {
     1145            *cp = savec;
     1146            if (savec != '\0') {
    11411147                cp++;
    11421148            }
    1143             while (*cp && isspace ((unsigned char) *cp)) {
     1149            while (*cp && isspace (*cp)) {
    11441150                cp++;
    11451151            }
     
    11561162             * and handle them accordingly.
    11571163             */
    1158             while (*cp && !isspace ((unsigned char) *cp)) {
     1164            while (*cp && !isspace (*cp)) {
    11591165                if ((*cp == '(') && (cp > line) && (cp[-1] != '$')) {
    11601166                    /*
     
    11711177
    11721178            if (*cp == '(') {
    1173                 GNode     *gnp;
     1179                GNode     *gn;
    11741180
    11751181                sources = Lst_Init (FALSE);
     
    11811187
    11821188                while (!Lst_IsEmpty (sources)) {
    1183                     gnp = (GNode *) Lst_DeQueue (sources);
    1184                     ParseDoSrc (tOp, gnp->name, curSrcs);
     1189                    gn = (GNode *) Lst_DeQueue (sources);
     1190                    ParseDoSrc (tOp, gn->name, curSrcs);
    11851191                }
    11861192                Lst_Destroy (sources, NOFREE);
     
    11941200                ParseDoSrc (tOp, line, curSrcs);
    11951201            }
    1196             while (*cp && isspace ((unsigned char) *cp)) {
     1202            while (*cp && isspace (*cp)) {
    11971203                cp++;
    11981204            }
     
    12011207    }
    12021208
    1203     if (mainNode == NULL) {
     1209    if (mainNode == NILGNODE) {
    12041210        /*
    12051211         * If we have yet to decide on a main target to make, in the
     
    12081214         * (i.e. isn't a .USE or .EXEC rule) to be made.
    12091215         */
    1210         Lst_ForEach (targets, ParseFindMain, (void *)0);
     1216        Lst_ForEach (targets, ParseFindMain, (ClientData)0);
    12111217    }
    12121218
     
    12341240 */
    12351241Boolean
    1236 Parse_IsVar (char *line)
    1237 {
    1238     Boolean wasSpace = FALSE;   /* set TRUE if found a space */
    1239     Boolean haveName = FALSE;   /* Set TRUE if have a variable name */
     1242Parse_IsVar (line)
     1243    register char  *line;       /* the line to check */
     1244{
     1245    register Boolean wasSpace = FALSE;  /* set TRUE if found a space */
     1246    register Boolean haveName = FALSE;  /* Set TRUE if have a variable name */
    12401247    int level = 0;
    1241 #define ISEQOPERATOR(c) \
     1248#define ISEQOPERATOR(c) \
    12421249        (((c) == '+') || ((c) == ':') || ((c) == '?') || ((c) == '!'))
    12431250
     
    13351342 */
    13361343void
    1337 Parse_DoVar (char *line, GNode *ctxt)
     1344Parse_DoVar (line, ctxt)
     1345    char            *line;      /* a line guaranteed to be a variable
     1346                                 * assignment. This reduces error checks */
     1347    GNode           *ctxt;      /* Context in which to do the assignment */
    13381348{
    13391349    char           *cp; /* pointer into line */
     
    13631373     */
    13641374    for (cp = line + 1; *cp != '='; cp++) {
    1365         if (isspace ((unsigned char) *cp)) {
     1375        if (isspace (*cp)) {
    13661376            *cp = '\0';
    13671377        }
     
    14191429    }
    14201430
    1421     while (isspace ((unsigned char) *cp)) {
     1431    while (isspace (*cp)) {
    14221432        cp++;
    14231433    }
     
    14401450
    14411451        oldVars = FALSE;
    1442 
    1443         /*
    1444          * make sure that we set the variable the first time to nothing
    1445          * so that it gets substituted!
    1446          */
    1447         if (!Var_Exists(line, ctxt))
    1448             Var_Set(line, "", ctxt);
    1449 
    14501452        cp = Var_Subst(NULL, cp, ctxt, FALSE);
    14511453        oldVars = oldOldVars;
     
    14561458        Boolean freeCmd = FALSE; /* TRUE if the command needs to be freed, i.e.
    14571459                                  * if any variable expansion was performed */
    1458         char *res, *error;
     1460        char *res, *err;
    14591461
    14601462        if (strchr(cp, '$') != NULL) {
     
    14681470        }
    14691471
    1470         res = Cmd_Exec(cp, &error);
     1472        res = Cmd_Exec(cp, &err);
    14711473        Var_Set(line, res, ctxt);
    14721474        free(res);
    14731475
    1474         if (error)
    1475             Parse_Error(PARSE_WARNING, error, cp);
     1476        if (err)
     1477            Parse_Error(PARSE_WARNING, err, cp);
    14761478
    14771479        if (freeCmd)
     
    14971499 */
    14981500static int
    1499 ParseAddCmd(void *gnp, void *cmd)
     1501ParseAddCmd(gnp, cmd)
     1502    ClientData gnp;     /* the node to which the command is to be added */
     1503    ClientData cmd;     /* the command to add */
    15001504{
    15011505    GNode *gn = (GNode *) gnp;
     
    15031507    if (!(gn->type & OP_HAS_COMMANDS))
    15041508        (void)Lst_AtEnd(gn->commands, cmd);
    1505     else
    1506         Parse_Error(PARSE_WARNING,
    1507                     "duplicate script for target \"%s\" ignored",
    1508                     gn->name);
    15091509    return(0);
    15101510}
     
    15271527 */
    15281528static void
    1529 ParseHasCommands(void *gnp)
     1529ParseHasCommands(gnp)
     1530    ClientData    gnp;      /* Node to examine */
    15301531{
    15311532    GNode *gn = (GNode *) gnp;
     
    15501551 */
    15511552void
    1552 Parse_AddIncludeDir (char *dir)
     1553Parse_AddIncludeDir (dir)
     1554    char          *dir;     /* The name of the directory to add */
    15531555{
    15541556    Dir_AddDir (parseIncPath, dir);
     
    15661568 */
    15671569static void
    1568 ParseDoError(char *errmsg)
    1569 {
    1570         if (!isspace((unsigned char) *errmsg)) {
     1570ParseDoError(errmsg)
     1571    char          *errmsg;      /* error message */
     1572{
     1573        if (!isspace(*errmsg)) {
    15711574                Parse_Error(PARSE_WARNING, "invalid syntax: .error%s", errmsg);
    15721575                return;
    15731576        }
    15741577       
    1575         while (isspace((unsigned char) *errmsg))
     1578        while (isspace(*errmsg))
    15761579                errmsg++;
    15771580       
     
    16021605 */
    16031606static void
    1604 ParseDoInclude (char *file)
     1607ParseDoInclude (file)
     1608    char          *file;        /* file specification */
    16051609{
    16061610    char          *fullname;    /* full pathname of file */
     
    17411745    oldFile->lineno = lineno;
    17421746
    1743     (void) Lst_AtFront (includes, (void *)oldFile);
     1747    (void) Lst_AtFront (includes, (ClientData)oldFile);
    17441748
    17451749    /*
     
    17791783 */
    17801784void
    1781 Parse_FromString(char *str)
     1785Parse_FromString(str)
     1786    char *str;
    17821787{
    17831788    IFile         *oldFile;     /* state associated with this file */
    17841789
    1785     DEBUGF(FOR, ("%s\n----\n", str));
     1790    if (DEBUG(FOR))
     1791        (void) fprintf(stderr, "%s\n----\n", str);
    17861792
    17871793    oldFile = (IFile *) emalloc (sizeof (IFile));
     
    17911797    oldFile->p = curPTR;
    17921798
    1793     (void) Lst_AtFront (includes, (void *)oldFile);
     1799    (void) Lst_AtFront (includes, (ClientData)oldFile);
    17941800
    17951801    curFILE = NULL;
     
    18191825 */
    18201826static void
    1821 ParseTraditionalInclude (char *file)
     1827ParseTraditionalInclude (file)
     1828    char          *file;        /* file specification */
    18221829{
    18231830    char          *fullname;    /* full pathname of file */
     
    19211928    oldFile->lineno = lineno;
    19221929
    1923     (void) Lst_AtFront (includes, (void *)oldFile);
     1930    (void) Lst_AtFront (includes, (ClientData)oldFile);
    19241931
    19251932    /*
     
    19601967 */
    19611968static int
    1962 ParseEOF (int opened)
     1969ParseEOF (opened)
     1970    int opened;
    19631971{
    19641972    IFile     *ifile;   /* the state on the top of the includes stack */
     
    19691977
    19701978    ifile = (IFile *) Lst_DeQueue (includes);
    1971     free (fname);
     1979    free ((Address) fname);
    19721980    fname = ifile->fname;
    19731981    lineno = ifile->lineno;
     
    19751983        (void) fclose (curFILE);
    19761984    if (curPTR) {
    1977         free(curPTR->str);
    1978         free(curPTR);
     1985        free((Address) curPTR->str);
     1986        free((Address) curPTR);
    19791987    }
    19801988    curFILE = ifile->F;
    19811989    curPTR = ifile->p;
    1982     free (ifile);
     1990    free ((Address)ifile);
    19831991    return (CONTINUE);
    19841992}
     
    19962004 */
    19972005static int
    1998 ParseReadc(void)
     2006ParseReadc()
    19992007{
    20002008    if (curFILE)
     
    20192027 */
    20202028static void
    2021 ParseUnreadc(int c)
     2029ParseUnreadc(c)
     2030    int c;
    20222031{
    20232032    if (curFILE) {
     
    20332042
    20342043/* ParseSkipLine():
    2035  *      Grab the next line unless it begins with a dot (`.') and we're told to
    2036  *      ignore such lines.
     2044 *      Grab the next line
    20372045 */
    20382046static char *
    2039 ParseSkipLine(int skip)
     2047ParseSkipLine(skip)
     2048    int skip;           /* Skip lines that don't start with . */
    20402049{
    20412050    char *line;
     
    20552064                lineno++;
    20562065
    2057                 while ((c = ParseReadc()) == ' ' || c == '\t')
    2058                     continue;
     2066                while ((c = ParseReadc()) == ' ' || c == '\t');
    20592067
    20602068                if (c == EOF)
     
    21002108 */
    21012109static char *
    2102 ParseReadLine (void)
     2110ParseReadLine ()
    21032111{
    21042112    Buffer        buf;          /* Buffer for current line */
    2105     int           c;            /* the current character */
    2106     int           lastc;        /* The most-recent character */
     2113    register int  c;            /* the current character */
     2114    register int  lastc;        /* The most-recent character */
    21072115    Boolean       semiNL;       /* treat semi-colons as newlines */
    21082116    Boolean       ignDepOp;     /* TRUE if should ignore dependency operators
     
    22212229            case '#':
    22222230                if (!ignComment) {
    2223                     if (lastc != '\\') {
     2231                    if (
     2232#if 0
     2233                    compatMake &&
     2234#endif
     2235                    (lastc != '\\')) {
    22242236                        /*
    22252237                         * If the character is a hash mark and it isn't escaped
     
    22522264                }
    22532265                break;
    2254             default:
    2255                 break;
    22562266            }
    22572267            /*
     
    22742284        /*
    22752285         * Strip trailing blanks and tabs from the line.
    2276          * Do not strip a blank or tab that is preceded by
     2286         * Do not strip a blank or tab that is preceeded by
    22772287         * a '\'
    22782288         */
     
    23052315                /*FALLTHRU*/
    23062316            case COND_PARSE:
    2307                 free (line);
     2317                free ((Address) line);
    23082318                line = ParseReadLine();
    23092319                break;
     
    23312341                }
    23322342                break;
    2333             default:
    2334                 break;
    23352343            }
    23362344        }
     
    23592367 */
    23602368static void
    2361 ParseFinishLine(void)
     2369ParseFinishLine()
    23622370{
    23632371    if (inLine) {
    2364         Lst_ForEach(targets, Suff_EndTransform, (void *)NULL);
     2372        Lst_ForEach(targets, Suff_EndTransform, (ClientData)NULL);
    23652373        Lst_Destroy (targets, ParseHasCommands);
    23662374        targets = NULL;
     
    23862394 */
    23872395void
    2388 Parse_File(char *name, FILE *stream)
    2389 {
    2390     char          *cp,          /* pointer into the line */
     2396Parse_File(name, stream)
     2397    char          *name;        /* the name of the file being read */
     2398    FILE *        stream;       /* Stream open to makefile to parse */
     2399{
     2400    register char *cp,          /* pointer into the line */
    23912401                  *line;        /* the line we're working on */
    23922402
     
    24042414                 * include or undef directives.
    24052415                 */
    2406                 for (cp = line + 1; isspace ((unsigned char) *cp); cp++) {
     2416                for (cp = line + 1; isspace (*cp); cp++) {
    24072417                    continue;
    24082418                }
     
    24432453            shellCommand:
    24442454#endif
    2445                 for (cp = line + 1; isspace ((unsigned char) *cp); cp++) {
     2455                for (cp = line + 1; isspace (*cp); cp++) {
    24462456                    continue;
    24472457                }
     
    24542464                         */
    24552465                        Lst_ForEach (targets, ParseAddCmd, cp);
    2456                         Lst_AtEnd(targCmds, (void *) line);
     2466                        Lst_AtEnd(targCmds, (ClientData) line);
    24572467                        continue;
    24582468                    } else {
     
    25692579 */
    25702580void
    2571 Parse_Init (void)
    2572 {
    2573     mainNode = NULL;
     2581Parse_Init ()
     2582{
     2583    mainNode = NILGNODE;
    25742584    parseIncPath = Lst_Init (FALSE);
    25752585    sysIncPath = Lst_Init (FALSE);
     
    25792589
    25802590void
    2581 Parse_End (void)
    2582 {
    2583     Lst_Destroy(targCmds, (void (*)(void *)) free);
     2591Parse_End()
     2592{
     2593    Lst_Destroy(targCmds, (void (*) __P((ClientData))) free);
    25842594    if (targets)
    25852595        Lst_Destroy(targets, NOFREE);
     
    26052615 */
    26062616Lst
    2607 Parse_MainName(void)
     2617Parse_MainName()
    26082618{
    26092619    Lst           listmain;     /* result list */
     
    26112621    listmain = Lst_Init (FALSE);
    26122622
    2613     if (mainNode == NULL) {
     2623    if (mainNode == NILGNODE) {
    26142624        Punt ("no target to make.");
    26152625        /*NOTREACHED*/
    26162626    } else if (mainNode->type & OP_DOUBLEDEP) {
    2617         (void) Lst_AtEnd (listmain, (void *)mainNode);
     2627        (void) Lst_AtEnd (listmain, (ClientData)mainNode);
    26182628        Lst_Concat(listmain, mainNode->cohorts, LST_CONCNEW);
    26192629    }
    26202630    else
    2621         (void) Lst_AtEnd (listmain, (void *)mainNode);
     2631        (void) Lst_AtEnd (listmain, (ClientData)mainNode);
    26222632    return (listmain);
    26232633}
Note: See TracChangeset for help on using the changeset viewer.