- Timestamp:
- Apr 22, 2007, 9:11:48 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/essentials/sys-apps/findutils/gnulib/lib/fts.c
r3170 r3179 77 77 # include "same-inode.h" 78 78 #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 79 87 80 88 #include <dirent.h> … … 495 503 } 496 504 505 #ifdef NEED_STRRSLASH 506 static 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 497 523 static void 498 524 internal_function … … 511 537 len = p->fts_pathlen = p->fts_namelen; 512 538 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 513 542 if ((cp = strrchr(p->fts_name, '/')) && (cp != p->fts_name || cp[1])) { 543 #endif 514 544 len = strlen(++cp); 515 545 memmove(p->fts_name, cp, len + 1); … … 579 609 */ 580 610 #define NAPPEND(p) \ 581 ( p->fts_path[p->fts_pathlen - 1] == '/'\611 (IS_SLASH(p->fts_path[p->fts_pathlen - 1]) \ 582 612 ? p->fts_pathlen - 1 : p->fts_pathlen) 583 613 … … 881 911 * fts_read will work. 882 912 */ 883 if (p->fts_level != FTS_ROOTLEVEL || p->fts_accpath[0] == '/'||913 if (p->fts_level != FTS_ROOTLEVEL || IS_SLASH(p->fts_accpath[0]) || 884 914 ISSET(FTS_NOCHDIR)) 885 915 return (sp->fts_child = fts_build(sp, instr)); … … 1004 1034 */ 1005 1035 if (nlinks || type == BREAD) { 1036 #ifdef __EMX__ 1037 if (fts_safe_changedir(sp, cur, -1, cur->fts_accpath)) { 1038 #else 1006 1039 int dir_fd = dirfd(dirp); 1007 1040 if (ISSET(FTS_CWDFD) && 0 <= dir_fd) 1008 1041 dir_fd = dup (dir_fd); 1009 1042 if (dir_fd < 0 || fts_safe_changedir(sp, cur, dir_fd, NULL)) { 1043 #endif 1010 1044 if (nlinks && type == BREAD) 1011 1045 cur->fts_errno = errno; … … 1013 1047 descend = false; 1014 1048 closedir(dirp); 1049 #ifndef __EMX__ 1015 1050 if (ISSET(FTS_CWDFD) && 0 <= dir_fd) 1016 1051 close (dir_fd); 1052 #endif 1017 1053 dirp = NULL; 1018 1054 } else
Note:
See TracChangeset
for help on using the changeset viewer.