mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Name USE_NAME_ON_FS constants
* dir.c (USE_NAME_ON_FS): name constants. * USE_NAME_ON_FS_REAL_BASENAME: platform dependent APIs to get real basenames. * USE_NAME_ON_FS_BY_FNMATCH: select the matching basename by fnmatch. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a77ef2c974
commit
65ca6391ed
1 changed files with 14 additions and 9 deletions
23
dir.c
23
dir.c
|
@ -83,14 +83,19 @@ char *strchr(char*,char);
|
|||
#include <sys/attr.h>
|
||||
#endif
|
||||
|
||||
#define USE_NAME_ON_FS_REAL_BASENAME 1 /* platform dependent APIs to
|
||||
* get real basenames */
|
||||
#define USE_NAME_ON_FS_BY_FNMATCH 2 /* select the matching
|
||||
* basename by fnmatch */
|
||||
|
||||
#ifdef HAVE_GETATTRLIST
|
||||
# define USE_NAME_ON_FS 1
|
||||
# define USE_NAME_ON_FS USE_NAME_ON_FS_REAL_BASENAME
|
||||
# define RUP32(size) ((size)+3/4)
|
||||
# define SIZEUP32(type) RUP32(sizeof(type))
|
||||
#elif defined _WIN32
|
||||
# define USE_NAME_ON_FS 1
|
||||
# define USE_NAME_ON_FS USE_NAME_ON_FS_REAL_BASENAME
|
||||
#elif defined DOSISH
|
||||
# define USE_NAME_ON_FS 2 /* by fnmatch */
|
||||
# define USE_NAME_ON_FS USE_NAME_ON_FS_BY_FNMATCH
|
||||
#else
|
||||
# define USE_NAME_ON_FS 0
|
||||
#endif
|
||||
|
@ -1638,7 +1643,7 @@ replace_real_basename(char *path, long base, rb_encoding *enc, int norm_p, int f
|
|||
}
|
||||
return path;
|
||||
}
|
||||
#elif USE_NAME_ON_FS == 1
|
||||
#elif USE_NAME_ON_FS == USE_NAME_ON_FS_REAL_BASENAME
|
||||
# error not implemented
|
||||
#endif
|
||||
|
||||
|
@ -1714,7 +1719,7 @@ glob_helper(
|
|||
plain = 1;
|
||||
break;
|
||||
case ALPHA:
|
||||
#if USE_NAME_ON_FS == 1
|
||||
#if USE_NAME_ON_FS == USE_NAME_ON_FS_REAL_BASENAME
|
||||
plain = 1;
|
||||
#else
|
||||
magical = 1;
|
||||
|
@ -1769,11 +1774,11 @@ glob_helper(
|
|||
if (magical || recursive) {
|
||||
struct dirent *dp;
|
||||
DIR *dirp;
|
||||
# if USE_NAME_ON_FS == 2
|
||||
# if USE_NAME_ON_FS == USE_NAME_ON_FS_BY_FNMATCH
|
||||
char *plainname = 0;
|
||||
# endif
|
||||
IF_NORMALIZE_UTF8PATH(int norm_p);
|
||||
# if USE_NAME_ON_FS == 2
|
||||
# if USE_NAME_ON_FS == USE_NAME_ON_FS_BY_FNMATCH
|
||||
if (cur + 1 == end && (*cur)->type <= ALPHA) {
|
||||
plainname = join_path(path, pathlen, dirsep, (*cur)->str, strlen((*cur)->str));
|
||||
if (!plainname) return -1;
|
||||
|
@ -1873,7 +1878,7 @@ glob_helper(
|
|||
}
|
||||
switch (p->type) {
|
||||
case ALPHA:
|
||||
# if USE_NAME_ON_FS == 2
|
||||
# if USE_NAME_ON_FS == USE_NAME_ON_FS_BY_FNMATCH
|
||||
if (plainname) {
|
||||
*new_end++ = p->next;
|
||||
break;
|
||||
|
@ -1945,7 +1950,7 @@ glob_helper(
|
|||
status = -1;
|
||||
break;
|
||||
}
|
||||
#if USE_NAME_ON_FS == 1
|
||||
#if USE_NAME_ON_FS == USE_NAME_ON_FS_REAL_BASENAME
|
||||
if ((*cur)->type == ALPHA) {
|
||||
long base = pathlen + (dirsep != 0);
|
||||
buf = replace_real_basename(buf, base, enc, IF_NORMALIZE_UTF8PATH(1)+0,
|
||||
|
|
Loading…
Reference in a new issue