Changeset 1328


Ignore:
Timestamp:
Mar 22, 2004, 8:38:43 PM (21 years ago)
Author:
bird
Message:

Ignore one trailing slash.

Location:
trunk/src/emx/src/lib/sys
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/lib/sys/__mkdir.c

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r1327 r1328  
    66#include <os2emx.h>
    77#include <stdlib.h>
     8#include <string.h>
    89#include <errno.h>
    910#include <emx/syscalls.h>
     
    1920    ULONG   rc;
    2021    int     cch;
     22    char    ch;
    2123    FS_VAR();
    2224
     
    4547
    4648    /*
     49     * Strip off any trailing slashes.
     50     * (Linux and FreeBSD accept this.)
     51     */
     52    if (cch <= 0)
     53    {
     54        cch = strlen(pszPath);
     55        if (    cch > 2
     56            && ((ch = pszPath[cch - 1]) == '/' || ch == '\\')
     57            && pszPath[cch - 2] != ':')
     58        {
     59            char *psz = alloca(cch);
     60            if (!psz)
     61            {
     62                errno = ENOMEM;
     63                LIBCLOG_RETURN_INT(-1);
     64            }
     65            pszPath = (const char *)memcpy(psz, pszPath, cch);
     66            psz[cch - 1] = '\0';
     67        }
     68    }
     69    else if (    cch > 3                /* includes terminator */
     70             && ((ch = pszPath[cch - 2]) == '/' || ch == '\\')
     71             && pszPath[cch - 3] != ':')
     72        ((char *)pszPath)[cch - 2] = '\0';          /* rewrite temp buffer. */
     73
     74
     75
     76    /*
    4777     * Do It.
    4878     */
  • trunk/src/emx/src/lib/sys/__rmdir.c

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r1327 r1328  
    55#include <os2emx.h>
    66#include <stdlib.h>
     7#include <string.h>
    78#include <errno.h>
    89#include <emx/syscalls.h>
     
    1718    ULONG   rc;
    1819    int     cch;
     20    char    ch;
    1921    FS_VAR();
    2022
     
    4345
    4446    /*
     47     * Strip off any trailing slashes.
     48     * (Linux and FreeBSD accept this.)
     49     */
     50    if (cch <= 0)
     51    {
     52        cch = strlen(pszPath);
     53        if (    cch > 2
     54            && ((ch = pszPath[cch - 1]) == '/' || ch == '\\')
     55            && pszPath[cch - 2] != ':')
     56        {
     57            char *psz = alloca(cch);
     58            if (!psz)
     59            {
     60                errno = ENOMEM;
     61                LIBCLOG_RETURN_INT(-1);
     62            }
     63            pszPath = (const char *)memcpy(psz, pszPath, cch);
     64            psz[cch - 1] = '\0';
     65        }
     66    }
     67    else if (    cch > 3                /* includes terminator */
     68             && ((ch = pszPath[cch - 2]) == '/' || ch == '\\')
     69             && pszPath[cch - 3] != ':')
     70        ((char *)pszPath)[cch - 2] = '\0';          /* rewrite temp buffer. */
     71
     72    /*
    4573     * Do It.
    4674     */
Note: See TracChangeset for help on using the changeset viewer.