Changeset 6141 for trunk/tools


Ignore:
Timestamp:
Jul 2, 2001, 8:21:02 PM (24 years ago)
Author:
bird
Message:

Quotes. Trim preprocessed lines. Read fixes. Empty dependant check. File header.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/fastdep/fastdep.c

    r5921 r6141  
    1 /* $Id: fastdep.c,v 1.27 2001-06-07 00:35:42 bird Exp $
     1/* $Id: fastdep.c,v 1.28 2001-07-02 18:21:02 bird Exp $
    22 *
    33 * Fast dependents. (Fast = Quick and Dirty!)
     
    215215INLINE char *trim(char *psz);
    216216INLINE char *trimR(char *psz);
     217INLINE char *trimQuotes(char *psz);
    217218
    218219/* preprocessors */
     
    787788                     * Make full path.
    788789                     */
    789                     if ((psz = strrchr(argv[argi], '\\')) || (psz = strrchr(argv[argi], '/')))
     790                    if ((psz = strrchr(argv[argi], '\\')) || (psz = strrchr(argv[argi], '/')) || (*(psz = &argv[argi][1]) == ':'))
    790791                    {
    791792                        strncpy(szSource, argv[argi], psz - argv[argi] + 1);
     
    27682769
    27692770/**
     2771 * Trims any quotes of a possibly quoted string.
     2772 * @returns   Pointer to the string passed in.
     2773 * @param     psz   Pointer to the string which is to be quote-trimmed.
     2774 * @status    completely implmented.
     2775 * @author    knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
     2776 */
     2777INLINE char *trimQuotes(char *psz)
     2778{
     2779    int i;
     2780    if (psz == NULL)
     2781        return NULL;
     2782
     2783    if (*psz == '\"' || *psz == '\'')
     2784        psz++;
     2785    i = strlen(psz) - 1;
     2786    if (psz[i] == '\"' || psz[i] == '\'')
     2787        psz[i] = '\0';
     2788
     2789    return psz;
     2790}
     2791
     2792
     2793/**
    27702794 * C/C++ preprocess a single line. Assumes that we're not starting
    27712795 * with at comment.
     
    28292853     */
    28302854    psz--;
    2831     while (psz >= pszOut && *psz == ' ' && *psz == '\t')
     2855    while (psz >= pszOut && (*psz == ' ' || *psz == '\t'))
    28322856        psz--;
    28332857    psz[1] = '\0';
     
    29813005
    29823006    /* get the filedate and subtract one month from it. */
    2983     if (!DosQueryPathInfo(pszFilename, FIL_STANDARD, &fst3, sizeof(fst3)))
     3007    if (!DosQueryPathInfo((PSZ)pszFilename, FIL_STANDARD, &fst3, sizeof(fst3)))
    29843008    {
    29853009        if (fst3.fdateLastWrite.month <= 1)
     
    30273051        cch = strlen(psz);
    30283052        if (cch == 0)
     3053        {
     3054            fMoreDeps = FALSE;
     3055            continue;
     3056        }
     3057
     3058        if (*psz == '#')
    30293059            continue;
    30303060
     
    30443074                {
    30453075                    static FDATE FileDate = {0,0,0};
     3076                    char *pszCont = strchr(&psz[i], '\\');
     3077                    fMoreDeps = pszCont != NULL && pszCont[1] == '\0';
     3078
    30463079                    psz[i] = '\0';
    3047                     pvRule = depAddRule(trimR(psz), NULL, NULL, FileDate);
     3080                    pvRule = depAddRule(trimQuotes(trimR(psz)), NULL, NULL, FileDate);
    30483081                    ((PDEPRULE)pvRule)->fUpdated = FALSE;
    30493082                    psz += i + 1;
    30503083                    cch -= i + 1;
    3051                     fMoreDeps = TRUE;
    30523084                    break;
    30533085                }
     
    30703102            if (pvRule != NULL)
    30713103            {
    3072                 psz = trim(psz);
     3104                psz = trimQuotes(trim(psz));
    30733105                if (*psz != '\0')
    30743106                    depAddDepend(pvRule, psz, options.fCheckCyclic);
     
    30993131        int         iBuffer = 0;
    31003132        int         cch;
     3133
     3134        /*
     3135         * Write warning on top of file.
     3136         */
     3137        fputs("#\n"
     3138              "# This file was automatically generated by FastDep.\n"
     3139              "# FastDep was written by knut st. osmundsen, and it's GPL software.\n"
     3140              "#\n"
     3141              "# THIS FILE SHOULD   N O T   BE EDITED MANUALLY!!!\n"
     3142              "#\n"
     3143              "# (As this may possibly make it unreadable for fastdep\n"
     3144              "#  and ruin the caching methods of FastDep.)\n"
     3145              "#\n"
     3146              "\n",
     3147              phFile);
     3148
    31013149
    31023150        /* @@@PH 2001-03-01
     
    31473195        while (pdep != NULL)
    31483196        {
     3197            int fQuoted = strpbrk(pdep->pszRule, " \t") != NULL; /* TODO/BUGBUG/FIXME: are there more special chars to look out for?? */
     3198
    31493199            /* Write rule. Flush the buffer first if necessary. */
    31503200            cch = strlen(pdep->pszRule);
    3151             if (iBuffer + cch + 2 >= sizeof(szBuffer))
     3201            if (iBuffer + cch + fQuoted * 2 + 2 >= sizeof(szBuffer))
    31523202            {
    31533203                fwrite(szBuffer, iBuffer, 1, phFile);
    31543204                iBuffer = 0;
    31553205            }
     3206            if (fQuoted) szBuffer[iBuffer++] = '"';
    31563207            strcpy(szBuffer + iBuffer, pdep->pszRule);
    31573208            iBuffer += cch;
     3209            if (fQuoted) szBuffer[iBuffer++] = '"';
    31583210            strcpy(szBuffer + iBuffer++, ":");
    31593211
     
    31653217                {
    31663218                    /* flush buffer? */
    3167                     if (iBuffer + strlen(*ppsz) + 20 >= sizeof(szBuffer))
     3219                    fQuoted = strpbrk(*ppsz, " \t") != NULL; /* TODO/BUGBUG/FIXME: are there more special chars to look out for?? */
     3220                    cch = strlen(*ppsz);
     3221                    if (iBuffer + cch + fQuoted * 2 + 20 >= sizeof(szBuffer))
    31683222                    {
    31693223                        fwrite(szBuffer, iBuffer, 1, phFile);
    31703224                        iBuffer = 0;
    31713225                    }
    3172                     iBuffer += sprintf(szBuffer + iBuffer, " \\\n    %s", *ppsz);
     3226                    strcpy(szBuffer + iBuffer, " \\\n    ");
     3227                    iBuffer += 7;
     3228                    if (fQuoted) szBuffer[iBuffer++] = '"';
     3229                    strcpy(szBuffer + iBuffer, *ppsz);
     3230                    iBuffer += cch;
     3231                    if (fQuoted) szBuffer[iBuffer++] = '"';
    31733232
    31743233                    /* next dependant */
     
    32913350         * Reuse the node in the tree.
    32923351         */
    3293         PDEPRULE    pOld = (PDEPRULE)(void*)AVLGet((PPAVLNODECORE)(void*)&pdepTree, pNew->avlCore.Key);
     3352        PDEPRULE    pOld = (PDEPRULE)AVLGet((PPAVLNODECORE)(void*)&pdepTree, pNew->avlCore.Key);
    32943353        assert(pOld);
    32953354        free(pNew);
     
    32983357
    32993358        pOld->fUpdated = TRUE;
    3300         if (!options.fForceScan && *(PUSHORT)(void*)&FileDate < *(PUSHORT)(void*)&options.fDepDate)
     3359        if (!options.fForceScan && *(PUSHORT)&FileDate < *(PUSHORT)&options.fDepDate)
    33013360            return NULL;
    33023361
     
    33273386{
    33283387    PDEPRULE pdep = (PDEPRULE)pvRule;
     3388
     3389    if (pszDep[0] == '\0')
     3390    {
     3391        fprintf(stderr, "warning-internal: empty dependancy filename to '%s'. Ignored.\n",
     3392                pdep->pszRule);
     3393        /* __interrupt(3); */
     3394        return FALSE;
     3395    }
    33293396
    33303397    if (fCheckCyclic && depCheckCyclic(pdep, pszDep))
Note: See TracChangeset for help on using the changeset viewer.