Ticket #304: remove-trailing-dots.diff

File remove-trailing-dots.diff, 674 bytes (added by KO Myung-Hun, 10 years ago)

Patch for trailing dots

  • src/lib/sys/fs.c

     
    817817        }
    818818    }
    819819
     820    /* Remove trailing dots except all dots. */
     821    pszTrg = pszPath + cch - 1;
     822
     823    /*
     824     * pszPath is an absolute path, that is, it has one '/' at least.
     825     * So, there is no need to check a boundary of pszTrg.
     826     */
     827    while (*pszTrg == '.')
     828        *pszTrg--;
     829
     830    /* Trailing dots ? Then remove them. */
     831    if (*pszTrg != '/')
     832        cch = pszTrg - pszPath + 1;
     833
     834    pszPath[cch] = '\0';
     835
    820836    return cch;
    821837}
    822838