Changeset 3148 for trunk/tools


Ignore:
Timestamp:
Mar 17, 2000, 8:26:50 PM (25 years ago)
Author:
bird
Message:

Bugfixing...

File:
1 edited

Legend:

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

    r3137 r3148  
    1 /* $Id: fastdep.c,v 1.13 2000-03-17 10:42:22 bird Exp $
     1/* $Id: fastdep.c,v 1.14 2000-03-17 19:26:50 bird Exp $
    22 *
    33 * Fast dependents. (Fast = Quick and Dirty!)
     
    293293    int         i;
    294294    const char *pszDepFile = pszDefaultDepFile;
     295    char        achBuffer[4096];
    295296
    296297    static char szObjectDir[CCHMAXPATH];
     
    334335    }
    335336    strlwr(szCurDir);
    336     for (i = 0, cSlashes; szCurDir[i] != '\0'; i++)
     337    aiSlashes[0] = 0;
     338    for (i = 1, cSlashes; szCurDir[i] != '\0'; i++)
    337339    {
    338340        if (szCurDir[i] == '/')
     
    506508
    507509        }
     510        else if (argv[argi][0] == '@')
     511        {   /*
     512             * Parameter file (debugger parameter length restrictions led to this):
     513             *    Create a textbuffer.
     514             *    Parse the file and create a new parameter vector.
     515             *    Set argv to the new parameter vector, argi to 0 and argc to
     516             *    the parameter count.
     517             *    Restrictions: Parameters enclosed in "" is not implemented.
     518             *                  No commandline parameters are processed after the @file
     519             */
     520            char *pszBuffer = (char*)textbufferCreate(&argv[argi][1]); /* !ASSUMS! that pvBuffer is the file string! */
     521            if (pszBuffer != NULL)
     522            {
     523                char **apszArgs = NULL;
     524                char *psz = pszBuffer;
     525                int  i = 0;
     526
     527                while (*psz != '\0')
     528                {
     529                    /* find end of parameter word */
     530                    char *pszEnd = psz + 1;
     531                    char  ch = *pszEnd;
     532                    while (ch != ' ' && ch != '\t' && ch != '\n' && ch != '\r' && ch != '\0')
     533                        ch = *++pszEnd;
     534
     535                    /* allocate more arg array space? */
     536                    if ((i % 512) == 0)
     537                    {
     538                        apszArgs = realloc(apszArgs, sizeof(char*) * 512);
     539                        if (apszArgs == NULL)
     540                        {
     541                            fprintf(stderr, "error: out of memory. (line=%d)\n", __LINE__);
     542                            return -8;
     543                        }
     544                    }
     545                    *pszEnd = '\0';
     546                    apszArgs[i++] = psz;
     547
     548                    /* next */
     549                    psz = pszEnd + 1;
     550                    ch = *psz;
     551                    while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r')
     552                        ch = *++psz;
     553                }
     554
     555                argc = i;
     556                argi = 0;
     557                argv = apszArgs;
     558                continue;
     559            }
     560            else
     561            {
     562                fprintf(stderr, "error: could not open parameter file\n");
     563                return -1;
     564            }
     565        }
    508566        else
    509567        {   /* not a parameter! */
    510568            ULONG           ulRc;
    511             char            achBuffer[4096];
    512569            PFILEFINDBUF3   pfindbuf3 = (PFILEFINDBUF3)(void*)&achBuffer[0];
    513570            HDIR            hDir = HDIR_CREATE;
     
    14071464
    14081465        strcpy(szFile, pszFilename);
    1409         iSlash = *psz == '\\' ? 0 : cSlashes;
     1466        iSlash = *psz == '\\' ? 1 : cSlashes;
    14101467        while (*psz != '\0')
    14111468        {
     
    14361493/**
    14371494 * Normalizes the path slashes for the filename. It will partially expand paths too.
     1495 * Makes name all lower case too.
    14381496 * @returns   pszFilename
    14391497 * @param     pszFilename  Pointer to filename string. Not empty string!
     
    14431501char *fileNormalize2(const char *pszFilename, char *pszBuffer)
    14441502{
    1445     char    *psz = pszBuffer;
    1446 
    1447     /* expand path? */
     1503    char psz = pszBuffer;
     1504    int     iSlash;
     1505
    14481506    if (pszFilename[1] != ':')
    1449     {   /* relative path */
    1450         int     iSlash;
    1451 
    1452         iSlash = *pszFilename == '\\' || *pszFilename == '/' ? 0 : cSlashes;
     1507    {
     1508        /* iSlash */
     1509        if (*pszFilename == '\\' || *pszFilename == '/')
     1510            iSlash = 1;
     1511        else
     1512            iSlash = cSlashes;
     1513
     1514        /* interpret . and .. */
    14531515        while (*pszFilename != '\0')
    14541516        {
     
    14641526            }
    14651527            else
    1466             {   /* completed expantion! */
     1528            {   /* completed expantion! - TODO ..\ or .\ may appare within the remaining path too... */
    14671529                strncpy(pszBuffer, szCurDir, aiSlashes[iSlash]+1);
    14681530                strcpy(pszBuffer + aiSlashes[iSlash]+1, pszFilename);
     
    14711533        }
    14721534    }
    1473     /* else: assume full path */
     1535    else
     1536    {   /* have drive letter specified - assume ok (TODO)*/
     1537        strcpy(pszBuffer, pszFilename);
     1538    }
    14741539
    14751540    /* correct slashes */
    14761541    while ((pszBuffer = strchr(pszBuffer, '//')) != NULL)
    14771542        *pszBuffer++ = '\\';
     1543
     1544    /* lower case it */
     1545    strlwr(psz);
    14781546
    14791547    return psz;
     
    21612229                        || psz[i+1] == '\t'
    21622230                        || psz[i+1] == '\0'
    2163                         || psz[i+1] == '\\'
     2231                        || (psz[i+1] == '\\' && psz[i+2] == '\0')
    21642232                        )
    21652233                    )
     2234                {
     2235                    psz[i] = '\0';
     2236                    pvRule = depAddRule(trimR(psz), NULL, NULL);
     2237                    psz += i + 1;
     2238                    cch -= i + 1;
     2239                    fMoreDeps = TRUE;
    21662240                    break;
     2241                }
    21672242                i++;
    2168             }
    2169 
    2170             if (psz[i] == ':')
    2171             {   /* new rule! */
    2172                 psz[i] = '\0';
    2173                 pvRule = depAddRule(trimR(psz), NULL, NULL);
    2174                 psz += i + 1;
    2175                 cch -= i + 1;
    2176                 fMoreDeps = TRUE;
    21772243            }
    21782244        }
Note: See TracChangeset for help on using the changeset viewer.