Changeset 3917


Ignore:
Timestamp:
Oct 24, 2014, 10:02:16 PM (10 years ago)
Author:
bird
Message:

0.6: fs.c,pathrewrite.c: Do a better job with trailing slashes on UNIXROOT env var, allow just a drive letter too. Straightened out a couple of style/doc issues in pathrewrite.c.

Location:
branches/libc-0.6/src/emx/src/lib/sys
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified branches/libc-0.6/src/emx/src/lib/sys/fs.c

    r3914 r3917  
    323323                && ((psz[0] >= 'A' && psz[0] <= 'Z') || (psz[0] >= 'a' && psz[0] <= 'z'))
    324324                && psz[1] == ':'
    325                 && (psz[2] == '\\' || psz[2] == '/')
     325                && (psz[2] == '\\' || psz[2] == '/' || psz[2] == '\0')
    326326                )
    327327            {
     
    339339                    __libc_gszUnixRoot[0] -= 'a' - 'A';
    340340
    341                 size_t off = cch;
    342                 while (off-- > 0)
    343                     if (__libc_gszUnixRoot[off] == '\\')
    344                         __libc_gszUnixRoot[off] = '/';
     341                if (cch == 2)
     342                {
     343                    __libc_gszUnixRoot[cch++] = '/';
     344                    __libc_gszUnixRoot[cch] = '\0';
     345                }
     346                else
     347                {
     348                    size_t off = cch;
     349                    while (off-- > 0)
     350                        if (__libc_gszUnixRoot[off] == '\\')
     351                            __libc_gszUnixRoot[off] = '/';
     352
     353                    while (cch > 3 && __libc_gszUnixRoot[cch - 1] == '/')
     354                        __libc_gszUnixRoot[--cch] = '\0';
     355                }
    345356
    346357                /* Register the rewrite rule. */
  • TabularUnified branches/libc-0.6/src/emx/src/lib/sys/pathrewrite.c

    r3780 r3917  
    660660        while ((ch = *pszEnd) && ch != '/' && ch != '\\')
    661661            pszEnd++;
    662         cch    = pszEnd - psz;
     662        cch = (unsigned)(pszEnd - psz);
    663663        if (cch > 255)
    664664        {
     
    707707                continue;
    708708            }
    709             else
    710             {
    711                 /*
    712                  * Complete match. We're done!
    713                  */
    714                 if (    pEntry->fType == DIRENTRY_TYPE_FILE
    715                     ||  pEntry->u.pDir->pRule /* DIRENTRY_TYPE_DIR */)
     709
     710            /*
     711             * Complete match. We're done!
     712             */
     713            if (    pEntry->fType == DIRENTRY_TYPE_FILE
     714                ||  pEntry->u.pDir->pRule /* DIRENTRY_TYPE_DIR */)
     715            {
     716                __LIBC_PPATHREWRITE pRule = pEntry->fType == DIRENTRY_TYPE_FILE
     717                                          ? pEntry->u.pFile : pEntry->u.pDir->pRule;
     718                cch = pRule->cchTo + 1;
     719                if (pszBuf)
    716720                {
    717                     __LIBC_PPATHREWRITE pRule = pEntry->fType == DIRENTRY_TYPE_FILE
    718                         ? pEntry->u.pFile : pEntry->u.pDir->pRule;
    719                     cch = pRule->cchTo + 1;
    720                     if (pszBuf)
    721                     {
    722                         if (cchBuf < cch)
    723                             LIBCLOG_ERROR_RETURN(-1, "ret -1 - Buffer is too small (%d < %d)\n", cchBuf, cch);
    724                         memcpy(pszBuf, pRule->pszTo, cch);
    725                         LIBCLOG_MSG("rewritten: '%s' (complete)\n", pszBuf);
    726                     }
    727                     LIBCLOG_RETURN_INT(cch);
     721                    if (cchBuf < cch)
     722                        LIBCLOG_ERROR_RETURN(-1, "ret -1 - Buffer is too small (%d < %d)\n", cchBuf, cch);
     723                    memcpy(pszBuf, pRule->pszTo, cch);
     724                    LIBCLOG_MSG("rewritten: '%s' (complete)\n", pszBuf);
    728725                }
    729                 /* not a match, the directory wasn't rewritten, quit searching. */
    730             }
     726                LIBCLOG_RETURN_INT(cch);
     727            }
     728            /* not a match, the directory wasn't rewritten, quit searching. */
    731729        }
    732730        /* no match, we're done. */
Note: See TracChangeset for help on using the changeset viewer.