[前][次][番号順一覧][スレッド一覧]

ruby-changes:38137

From: nobu <ko1@a...>
Date: Fri, 10 Apr 2015 23:57:56 +0900 (JST)
Subject: [ruby-changes:38137] nobu:r50218 (trunk): dir.c: getattrlist on OSX 10.5

nobu	2015-04-10 23:57:47 +0900 (Fri, 10 Apr 2015)

  New Revision: 50218

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50218

  Log:
    dir.c: getattrlist on OSX 10.5
    
    * dir.c (need_normalization): use getattrlist() if fgetattrlist()
      is unavailable, on OSX 10.5.  [ruby-core:68829] [Bug #11054]

  Modified files:
    trunk/ChangeLog
    trunk/configure.in
    trunk/dir.c
Index: configure.in
===================================================================
--- configure.in	(revision 50217)
+++ configure.in	(revision 50218)
@@ -2091,6 +2091,7 @@ AC_CHECK_FUNCS(fchmod) https://github.com/ruby/ruby/blob/trunk/configure.in#L2091
 AC_CHECK_FUNCS(fchown)
 AC_CHECK_FUNCS(fcntl)
 AC_CHECK_FUNCS(fdatasync)
+AC_CHECK_FUNCS(fgetattrlist)
 AC_CHECK_FUNCS(fmod)
 AC_CHECK_FUNCS(fsync)
 AC_CHECK_FUNCS(ftruncate)
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 50217)
+++ ChangeLog	(revision 50218)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Apr 10 23:57:44 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* dir.c (need_normalization): use getattrlist() if fgetattrlist()
+	  is unavailable, on OSX 10.5.  [ruby-core:68829] [Bug #11054]
+
 Fri Apr 10 22:29:21 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/mkmf.rb (try_compile): pass the given werror flag to try_do
Index: dir.c
===================================================================
--- dir.c	(revision 50217)
+++ dir.c	(revision 50218)
@@ -103,13 +103,23 @@ char *strchr(char*,char); https://github.com/ruby/ruby/blob/trunk/dir.c#L103
 #include <sys/mount.h>
 #include <sys/vnode.h>
 
+# if defined HAVE_FGETATTRLIST || !defined HAVE_GETATTRLIST
+#   define need_normalization(dirp, path) need_normalization(dirp)
+# else
+#   define need_normalization(dirp, path) need_normalization(path)
+# endif
 static inline int
-need_normalization(DIR *dirp)
+need_normalization(DIR *dirp, const char *path)
 {
-# ifdef HAVE_GETATTRLIST
+# if defined HAVE_FGETATTRLIST || defined HAVE_GETATTRLIST
     u_int32_t attrbuf[SIZEUP32(fsobj_tag_t)];
     struct attrlist al = {ATTR_BIT_MAP_COUNT, 0, ATTR_CMN_OBJTAG,};
-    if (!fgetattrlist(dirfd(dirp), &al, attrbuf, sizeof(attrbuf), 0)) {
+#   if defined HAVE_FGETATTRLIST
+    int ret = fgetattrlist(dirfd(dirp), &al, attrbuf, sizeof(attrbuf), 0);
+#   else
+    int ret = getattrlist(path, &al, attrbuf, sizeof(attrbuf), 0);
+#   endif
+    if (!ret) {
 	const fsobj_tag_t *tag = (void *)(attrbuf+1);
 	switch (*tag) {
 	  case VT_HFS:
@@ -699,7 +709,7 @@ dir_each(VALUE dir) https://github.com/ruby/ruby/blob/trunk/dir.c#L709
     RETURN_ENUMERATOR(dir, 0, 0);
     GetDIR(dir, dirp);
     rewinddir(dirp->dir);
-    IF_NORMALIZE_UTF8PATH(norm_p = need_normalization(dirp->dir));
+    IF_NORMALIZE_UTF8PATH(norm_p = need_normalization(dirp->dir, RSTRING_PTR(dirp->path)));
     while ((dp = READDIR(dirp->dir, dirp->enc)) != NULL) {
 	const char *name = dp->d_name;
 	size_t namlen = NAMLEN(dp);
@@ -1701,7 +1711,7 @@ glob_helper( https://github.com/ruby/ruby/blob/trunk/dir.c#L1711
 # endif
 	    return 0;
 	}
-	IF_NORMALIZE_UTF8PATH(norm_p = need_normalization(dirp));
+	IF_NORMALIZE_UTF8PATH(norm_p = need_normalization(dirp, *path ? path : "."));
 
 # if NORMALIZE_UTF8PATH
 	if (!(norm_p || magical || recursive)) {

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]