[53203] trunk/base/src/pextlib1.0

toby at macports.org toby at macports.org
Tue Jun 30 23:13:19 PDT 2009


Revision: 53203
          http://trac.macports.org/changeset/53203
Author:   toby at macports.org
Date:     2009-06-30 23:13:19 -0700 (Tue, 30 Jun 2009)
Log Message:
-----------
break readdir out into its own file

Modified Paths:
--------------
    trunk/base/src/pextlib1.0/Makefile
    trunk/base/src/pextlib1.0/Pextlib.c

Added Paths:
-----------
    trunk/base/src/pextlib1.0/readdir.c
    trunk/base/src/pextlib1.0/readdir.h

Modified: trunk/base/src/pextlib1.0/Makefile
===================================================================
--- trunk/base/src/pextlib1.0/Makefile	2009-07-01 06:04:07 UTC (rev 53202)
+++ trunk/base/src/pextlib1.0/Makefile	2009-07-01 06:13:19 UTC (rev 53203)
@@ -2,7 +2,7 @@
 		fs-traverse.o strcasecmp.o vercomp.o filemap.o \
 		sha1cmd.o curl.o rmd160cmd.o readline.o uid.o\
 		tracelib.o tty.o get_systemconfiguration_proxies.o\
-		sysctl.o
+		sysctl.o readdir.o
 SHLIB_NAME=	Pextlib${SHLIB_SUFFIX}
 INSTALLDIR= ${DESTDIR}${datadir}/macports/Tcl/pextlib1.0
 

Modified: trunk/base/src/pextlib1.0/Pextlib.c
===================================================================
--- trunk/base/src/pextlib1.0/Pextlib.c	2009-07-01 06:04:07 UTC (rev 53202)
+++ trunk/base/src/pextlib1.0/Pextlib.c	2009-07-01 06:13:19 UTC (rev 53203)
@@ -48,10 +48,6 @@
 #include <strings.h>
 #endif
 
-#if HAVE_DIRENT_H
-#include <dirent.h>
-#endif
-
 #if HAVE_LIMITS_H
 #include <limits.h>
 #endif
@@ -115,6 +111,7 @@
 #include "get_systemconfiguration_proxies.h"
 #include "sysctl.h"
 #include "strsed.h"
+#include "readdir.h"
 
 #if HAVE_CRT_EXTERNS_H
 #include <crt_externs.h>
@@ -663,47 +660,6 @@
 	return TCL_OK;
 }
 
-/**
- *
- * Return the list of elements in a directory.
- * Since 1.60.4.2, the list doesn't include . and ..
- *
- * Synopsis: readdir directory
- */
-int ReaddirCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
-{
-	DIR *dirp;
-	struct dirent *mp;
-	Tcl_Obj *tcl_result;
-	char *path;
-
-	if (objc != 2) {
-		Tcl_WrongNumArgs(interp, 1, objv, "directory");
-		return TCL_ERROR;
-	}
-
-	path = Tcl_GetString(objv[1]);
-	dirp = opendir(path);
-	if (!dirp) {
-		Tcl_SetResult(interp, "Cannot read directory", TCL_STATIC);
-		return TCL_ERROR;
-	}
-	tcl_result = Tcl_NewListObj(0, NULL);
-	while ((mp = readdir(dirp))) {
-		/* Skip . and .. */
-		if ((mp->d_name[0] != '.') ||
-			((mp->d_name[1] != 0)	/* "." */
-				&&
-			((mp->d_name[1] != '.') || (mp->d_name[2] != 0)))) /* ".." */ {
-			Tcl_ListObjAppendElement(interp, tcl_result, Tcl_NewStringObj(mp->d_name, -1));
-		}
-	}
-	closedir(dirp);
-	Tcl_SetObjResult(interp, tcl_result);
-	
-	return TCL_OK;
-}
-
 int StrsedCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 {
 	char *pattern, *string, *res;

Added: trunk/base/src/pextlib1.0/readdir.c
===================================================================
--- trunk/base/src/pextlib1.0/readdir.c	                        (rev 0)
+++ trunk/base/src/pextlib1.0/readdir.c	2009-07-01 06:13:19 UTC (rev 53203)
@@ -0,0 +1,52 @@
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <tcl.h>
+
+#if HAVE_DIRENT_H
+#include <dirent.h>
+#endif
+
+#include "readdir.h"
+
+/**
+ *
+ * Return the list of elements in a directory.
+ * Since 1.60.4.2, the list doesn't include . and ..
+ *
+ * Synopsis: readdir directory
+ */
+int ReaddirCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
+{
+	DIR *dirp;
+	struct dirent *mp;
+	Tcl_Obj *tcl_result;
+	char *path;
+
+	if (objc != 2) {
+		Tcl_WrongNumArgs(interp, 1, objv, "directory");
+		return TCL_ERROR;
+	}
+
+	path = Tcl_GetString(objv[1]);
+	dirp = opendir(path);
+	if (!dirp) {
+		Tcl_SetResult(interp, "Cannot read directory", TCL_STATIC);
+		return TCL_ERROR;
+	}
+	tcl_result = Tcl_NewListObj(0, NULL);
+	while ((mp = readdir(dirp))) {
+		/* Skip . and .. */
+		if ((mp->d_name[0] != '.') ||
+			((mp->d_name[1] != 0)	/* "." */
+				&&
+			((mp->d_name[1] != '.') || (mp->d_name[2] != 0)))) /* ".." */ {
+			Tcl_ListObjAppendElement(interp, tcl_result, Tcl_NewStringObj(mp->d_name, -1));
+		}
+	}
+	closedir(dirp);
+	Tcl_SetObjResult(interp, tcl_result);
+	
+	return TCL_OK;
+}

Added: trunk/base/src/pextlib1.0/readdir.h
===================================================================
--- trunk/base/src/pextlib1.0/readdir.h	                        (rev 0)
+++ trunk/base/src/pextlib1.0/readdir.h	2009-07-01 06:13:19 UTC (rev 53203)
@@ -0,0 +1 @@
+int ReaddirCmd(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST objv[]);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090630/7c0c7b86/attachment.html>


More information about the macports-changes mailing list