Changeset 30 for trunk/src/kmk/var.c


Ignore:
Timestamp:
Nov 30, 2002, 7:53:42 AM (23 years ago)
Author:
bird
Message:

Basic nmake emulation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/var.c

    r27 r30  
    183183static Boolean VarSuffix __P((char *, Boolean, Buffer, ClientData));
    184184static Boolean VarRoot __P((char *, Boolean, Buffer, ClientData));
     185#ifdef NMAKE
     186static Boolean VarBase __P((char *, Boolean, Buffer, ClientData));
     187#endif
    185188static Boolean VarMatch __P((char *, Boolean, Buffer, ClientData));
    186189#ifdef SYSVVARSUB
     
    795798    return (dummy ? TRUE : TRUE);
    796799}
     800
     801#ifdef NMAKE
     802/*-
     803 *-----------------------------------------------------------------------
     804 * VarBase --
     805 *      Remove the head and suffix of the given word and place the result
     806 *      in the given buffer.
     807 *
     808 * Results:
     809 *      TRUE if characters were added to the buffer (a space needs to be
     810 *      added to the buffer before the next word).
     811 *
     812 * Side Effects:
     813 *      The trimmed word is added to the buffer.
     814 *
     815 *-----------------------------------------------------------------------
     816 */
     817static Boolean
     818VarBase (word, addSpace, buf, dummy)
     819    char          *word;        /* Word to trim */
     820    Boolean       addSpace;     /* TRUE if need to stick a space in the
     821                                 * buffer before adding the tail */
     822    Buffer        buf;          /* Buffer in which to store it */
     823    ClientData    dummy;
     824{
     825    register char *slash;
     826
     827    if (addSpace) {
     828        Buf_AddByte (buf, (Byte)' ');
     829    }
     830
     831    slash = strrchr (word, '/');
     832    if (slash != (char *)NULL) {
     833        register char *dot;
     834        *slash++ = '\0';
     835        dot = strrchr (slash, '.');
     836        if (dot)
     837        {
     838            *dot = '\0';
     839            Buf_AddBytes (buf, strlen(slash), (Byte *)slash);
     840            *dot = '.';
     841        }
     842        else
     843            Buf_AddBytes (buf, strlen(slash), (Byte *)slash);
     844        slash[-1] = '/';
     845    } else {
     846        register char *dot;
     847        dot = strrchr (slash, '.');
     848        if (dot)
     849        {
     850            *dot = '\0';
     851            Buf_AddBytes (buf, strlen(slash), (Byte *)slash);
     852            *dot = '.';
     853        }
     854        else
     855            Buf_AddBytes (buf, strlen(slash), (Byte *)slash);
     856    }
     857    return (dummy ? TRUE : TRUE);
     858}
     859
     860#endif
    797861
    798862/*-
     
    14961560    dynamic = FALSE;
    14971561    start = str;
     1562//debugkso: fprintf(stderr, "var: str=%s\n", str);
    14981563
    14991564    if (str[1] != '(' && str[1] != '{') {
     
    15901655        v = VarFind (str, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD);
    15911656        if ((v == (Var *)NIL) && (ctxt != VAR_CMD) && (ctxt != VAR_GLOBAL) &&
     1657#ifdef NMAKE
     1658            (vlen == 2) && (str[1] == 'F' || str[1] == 'D' || str[1] == 'B' || str[1] == 'R'))
     1659#else
    15921660            (vlen == 2) && (str[1] == 'F' || str[1] == 'D'))
     1661#endif
    15931662        {
    15941663            /*
     
    16221691                        val = (char *)Buf_GetAll(v->val, (int *)NULL);
    16231692
     1693#ifdef NMAKE
     1694                        switch (str[1])
     1695                        {
     1696                        case 'D': val = VarModify(val, VarHead, (ClientData)0); break;
     1697                        case 'B': val = VarModify(val, VarBase, (ClientData)0); break;
     1698                        case 'R': val = VarModify(val, VarRoot, (ClientData)0); break;
     1699                        default:  val = VarModify(val, VarTail, (ClientData)0); break;
     1700                        }
     1701#else
    16241702                        if (str[1] == 'D') {
    16251703                            val = VarModify(val, VarHead, (ClientData)0);
     
    16271705                            val = VarModify(val, VarTail, (ClientData)0);
    16281706                        }
     1707#endif
    16291708                        /*
    16301709                         * Resulting string is dynamically allocated, so
     
    16431722
    16441723        if (v == (Var *)NIL) {
     1724//debugkso: fprintf(stderr, "\tv == (Var *)NIL vlen=%d str=%s\n", vlen, str);
     1725
    16451726            if (((vlen == 1) ||
    16461727                 (((vlen == 2) && (str[1] == 'F' ||
     1728#ifdef NMAKE
     1729                                         str[1] == 'D' || str[1] == 'B' || str[1] == 'R')))) &&
     1730#else
    16471731                                         str[1] == 'D')))) &&
     1732#endif
    16481733                ((ctxt == VAR_CMD) || (ctxt == VAR_GLOBAL)))
    16491734            {
Note: See TracChangeset for help on using the changeset viewer.