Changeset 3179 for trunk


Ignore:
Timestamp:
Apr 22, 2007, 9:11:48 AM (18 years ago)
Author:
bird
Message:

Why can't these guys just use the libc fts when present. crap.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/essentials/sys-apps/findutils/gnulib/lib/fts.c

    r3170 r3179  
    7777# include "same-inode.h"
    7878#endif
     79
     80# if defined(__OS2__) || defined(__NT__) || defined(__WIN__)
     81# define NEED_STRRSLASH 1
     82# define IS_SLASH(ch)   ( (ch) == '/' || (ch) == '\\' )
     83#else
     84# define IS_SLASH(ch)   ( (ch) == '/' )
     85#endif
     86
    7987
    8088#include <dirent.h>
     
    495503}
    496504
     505#ifdef NEED_STRRSLASH
     506static char *strrslash(register char *psz)
     507{
     508    register char ch;
     509    char *pszLast = NULL;
     510    for (; (ch = *psz); psz++)
     511        switch (ch)
     512        {
     513            case '/':
     514            case '\\':
     515            case ':':
     516                pszLast = psz;
     517                break;
     518        }
     519    return pszLast;
     520}
     521#endif
     522
    497523static void
    498524internal_function
     
    511537        len = p->fts_pathlen = p->fts_namelen;
    512538        memmove(sp->fts_path, p->fts_name, len + 1);
     539#ifdef NEED_STRRSLASH
     540        if ((cp = strrslash(p->fts_name)) && (cp != p->fts_name || cp[1])) {
     541#else
    513542        if ((cp = strrchr(p->fts_name, '/')) && (cp != p->fts_name || cp[1])) {
     543#endif
    514544                len = strlen(++cp);
    515545                memmove(p->fts_name, cp, len + 1);
     
    579609 */
    580610#define NAPPEND(p)                                                      \
    581         (p->fts_path[p->fts_pathlen - 1] == '/'                         \
     611        (IS_SLASH(p->fts_path[p->fts_pathlen - 1])                              \
    582612            ? p->fts_pathlen - 1 : p->fts_pathlen)
    583613
     
    881911         * fts_read will work.
    882912         */
    883         if (p->fts_level != FTS_ROOTLEVEL || p->fts_accpath[0] == '/' ||
     913        if (p->fts_level != FTS_ROOTLEVEL || IS_SLASH(p->fts_accpath[0]) ||
    884914            ISSET(FTS_NOCHDIR))
    885915                return (sp->fts_child = fts_build(sp, instr));
     
    10041034         */
    10051035        if (nlinks || type == BREAD) {
     1036#ifdef __EMX__
     1037                if (fts_safe_changedir(sp, cur, -1, cur->fts_accpath)) {
     1038#else
    10061039                int dir_fd = dirfd(dirp);
    10071040                if (ISSET(FTS_CWDFD) && 0 <= dir_fd)
    10081041                  dir_fd = dup (dir_fd);
    10091042                if (dir_fd < 0 || fts_safe_changedir(sp, cur, dir_fd, NULL)) {
     1043#endif
    10101044                        if (nlinks && type == BREAD)
    10111045                                cur->fts_errno = errno;
     
    10131047                        descend = false;
    10141048                        closedir(dirp);
     1049#ifndef __EMX__
    10151050                        if (ISSET(FTS_CWDFD) && 0 <= dir_fd)
    10161051                                close (dir_fd);
     1052#endif
    10171053                        dirp = NULL;
    10181054                } else
Note: See TracChangeset for help on using the changeset viewer.