[commit: packages/unix] master: Merge dirUtils.c into HsUnix.c (b54bd5f)

git at git.haskell.org git at git.haskell.org
Tue Apr 19 21:38:19 UTC 2016


Repository : ssh://git@git.haskell.org/unix

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/b54bd5fc4355af6104b80a48353889bbd867ba10/unix

>---------------------------------------------------------------

commit b54bd5fc4355af6104b80a48353889bbd867ba10
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date:   Sun Jan 31 11:31:14 2016 +0100

    Merge dirUtils.c into HsUnix.c


>---------------------------------------------------------------

b54bd5fc4355af6104b80a48353889bbd867ba10
 cbits/HsUnix.c   | 62 ++++++++++++++++++++++++++++++++++++++++++++++++
 cbits/dirUtils.c | 72 --------------------------------------------------------
 unix.cabal       |  1 -
 3 files changed, 62 insertions(+), 73 deletions(-)

diff --git a/cbits/HsUnix.c b/cbits/HsUnix.c
index d689a6e..25fd8ad 100644
--- a/cbits/HsUnix.c
+++ b/cbits/HsUnix.c
@@ -71,3 +71,65 @@ HsInt __hsunix_long_path_size(void) {
 #endif
 }
 
+
+/*
+ * read an entry from the directory stream; opt for the
+ * re-entrant friendly way of doing this, if available.
+ */
+int __hscore_readdir( DIR *dirPtr, struct dirent **pDirEnt )
+{
+#if HAVE_READDIR_R
+  struct dirent* p;
+  int res;
+  static unsigned int nm_max = (unsigned int)-1;
+
+  if (pDirEnt == NULL) {
+    return -1;
+  }
+  if (nm_max == (unsigned int)-1) {
+#ifdef NAME_MAX
+    nm_max = NAME_MAX + 1;
+#else
+    nm_max = pathconf(".", _PC_NAME_MAX);
+    if (nm_max == -1) { nm_max = 255; }
+    nm_max++;
+#endif
+  }
+  p = (struct dirent*)malloc(sizeof(struct dirent) + nm_max);
+  if (p == NULL) return -1;
+  res = readdir_r(dirPtr, p, pDirEnt);
+  if (res != 0) {
+      *pDirEnt = NULL;
+      free(p);
+  }
+  else if (*pDirEnt == NULL) {
+    // end of stream
+    free(p);
+  }
+  return res;
+#else
+
+  if (pDirEnt == NULL) {
+    return -1;
+  }
+
+  *pDirEnt = readdir(dirPtr);
+  if (*pDirEnt == NULL) {
+    return -1;
+  } else {
+    return 0;
+  }
+#endif
+}
+
+char *__hscore_d_name( struct dirent* d )
+{
+  return (d->d_name);
+}
+
+void __hscore_free_dirent(struct dirent *dEnt)
+{
+#if HAVE_READDIR_R
+  free(dEnt);
+#endif
+}
diff --git a/cbits/dirUtils.c b/cbits/dirUtils.c
deleted file mode 100644
index 0a645eb..0000000
--- a/cbits/dirUtils.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/* 
- * (c) The University of Glasgow 2002
- *
- * Directory Runtime Support
- */
-
-#include "HsUnix.h"
-
-/*
- * read an entry from the directory stream; opt for the
- * re-entrant friendly way of doing this, if available.
- */
-int
-__hscore_readdir( DIR *dirPtr, struct dirent **pDirEnt )
-{
-#if HAVE_READDIR_R
-  struct dirent* p;
-  int res;
-  static unsigned int nm_max = (unsigned int)-1;
-  
-  if (pDirEnt == NULL) {
-    return -1;
-  }
-  if (nm_max == (unsigned int)-1) {
-#ifdef NAME_MAX
-    nm_max = NAME_MAX + 1;
-#else
-    nm_max = pathconf(".", _PC_NAME_MAX);
-    if (nm_max == -1) { nm_max = 255; }
-    nm_max++;
-#endif
-  }
-  p = (struct dirent*)malloc(sizeof(struct dirent) + nm_max);
-  if (p == NULL) return -1;
-  res = readdir_r(dirPtr, p, pDirEnt);
-  if (res != 0) {
-      *pDirEnt = NULL;
-      free(p);
-  }
-  else if (*pDirEnt == NULL) {
-    // end of stream
-    free(p);
-  }
-  return res;
-#else
-
-  if (pDirEnt == NULL) {
-    return -1;
-  }
-
-  *pDirEnt = readdir(dirPtr);
-  if (*pDirEnt == NULL) {
-    return -1;
-  } else {
-    return 0;
-  }  
-#endif
-}
-
-char *
-__hscore_d_name( struct dirent* d )
-{
-  return (d->d_name);
-}
-
-void
-__hscore_free_dirent(struct dirent *dEnt)
-{
-#if HAVE_READDIR_R
-  free(dEnt);
-#endif
-}
diff --git a/unix.cabal b/unix.cabal
index 2027559..02d583e 100644
--- a/unix.cabal
+++ b/unix.cabal
@@ -131,5 +131,4 @@ library
         execvpe.h
     c-sources:
         cbits/HsUnix.c
-        cbits/dirUtils.c
         cbits/execvpe.c



More information about the ghc-commits mailing list