From 65ca6391edd684f1b23750bbcdac7fa3e27b86aa Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 20 Jun 2016 11:00:17 +0000 Subject: [PATCH] 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 --- dir.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/dir.c b/dir.c index eb89d23894..d1bd2e4003 100644 --- a/dir.c +++ b/dir.c @@ -83,14 +83,19 @@ char *strchr(char*,char); #include #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,