[24112] trunk/base

source_changes at macosforge.org source_changes at macosforge.org
Mon Apr 16 17:06:49 PDT 2007


Revision: 24112
          http://trac.macosforge.org/projects/macports/changeset/24112
Author:   eridius at macports.org
Date:     2007-04-16 17:06:48 -0700 (Mon, 16 Apr 2007)

Log Message:
-----------
Rename find to fs-traverse. At this moment we no longer have a find command, but the intention is to write one that behaves like find(1)

Modified Paths:
--------------
    trunk/base/ChangeLog
    trunk/base/doc/portfile.7
    trunk/base/src/pextlib1.0/Makefile
    trunk/base/src/pextlib1.0/Pextlib.c

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

Removed Paths:
-------------
    trunk/base/src/pextlib1.0/find.c
    trunk/base/src/pextlib1.0/find.h

Modified: trunk/base/ChangeLog
===================================================================
--- trunk/base/ChangeLog	2007-04-16 23:55:54 UTC (rev 24111)
+++ trunk/base/ChangeLog	2007-04-17 00:06:48 UTC (rev 24112)
@@ -10,8 +10,8 @@
     - New logic for variants overload that basically yields to listing only
       variant +universal on ports that redefine it (pguyot in 24100).
 
-    - Implement brand new find command in Pextlib.
-      See portfile.7 for documentation (eridius in r24079 and r24080).
+    - Implement brand new fs-traverse command in Pextlib.
+      See portfile.7 for documentation (eridius in r24079, r24080, and r24112).
 
     - Add per-user preferences in ~/.macports/user.conf. This will be used
       for submitter information.

Modified: trunk/base/doc/portfile.7
===================================================================
--- trunk/base/doc/portfile.7	2007-04-16 23:55:54 UTC (rev 24111)
+++ trunk/base/doc/portfile.7	2007-04-17 00:06:48 UTC (rev 24112)
@@ -1482,7 +1482,7 @@
 .El
 .El
 .It Xo
-.Ic find
+.Ic fs-traverse
 .Op Fl depth
 .Op Fl ignoreErrors
 .Ar varname
@@ -1515,7 +1515,7 @@
 as it will be processed after its children.
 .It Fl ignoreErrors
 Causes
-.Nm find
+.Nm fs-traverse
 to ignore any permissions/read errors encountered during processing.
 .El
 .It Xo

Modified: trunk/base/src/pextlib1.0/Makefile
===================================================================
--- trunk/base/src/pextlib1.0/Makefile	2007-04-16 23:55:54 UTC (rev 24111)
+++ trunk/base/src/pextlib1.0/Makefile	2007-04-17 00:06:48 UTC (rev 24112)
@@ -1,5 +1,5 @@
 OBJS=		Pextlib.o strsed.o fgetln.o md5cmd.o setmode.o xinstall.o \
-		find.o strcasecmp.o vercomp.o filemap.o \
+		fs-traverse.o strcasecmp.o vercomp.o filemap.o \
 		sha1cmd.o compat.o curl.o rmd160cmd.o readline.o uid.o
 SHLIB_NAME=	Pextlib${SHLIB_SUFFIX}
 INSTALLDIR= ${DESTDIR}${datadir}/darwinports/Tcl/pextlib1.0

Modified: trunk/base/src/pextlib1.0/Pextlib.c
===================================================================
--- trunk/base/src/pextlib1.0/Pextlib.c	2007-04-16 23:55:54 UTC (rev 24111)
+++ trunk/base/src/pextlib1.0/Pextlib.c	2007-04-17 00:06:48 UTC (rev 24112)
@@ -105,7 +105,7 @@
 #include "md5cmd.h"
 #include "sha1cmd.h"
 #include "rmd160cmd.h"
-#include "find.h"
+#include "fs-traverse.h"
 #include "filemap.h"
 #include "curl.h"
 #include "xinstall.h"
@@ -1111,7 +1111,7 @@
 	Tcl_CreateObjCommand(interp, "nextgid", NextgidCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "md5", MD5Cmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "xinstall", InstallCmd, NULL, NULL);
-	Tcl_CreateObjCommand(interp, "find", FindCmd, NULL, NULL);
+	Tcl_CreateObjCommand(interp, "fs-traverse", FsTraverseCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "filemap", FilemapCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "rpm-vercomp", RPMVercompCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "rmd160", RMD160Cmd, NULL, NULL);

Deleted: trunk/base/src/pextlib1.0/find.c
===================================================================
--- trunk/base/src/pextlib1.0/find.c	2007-04-16 23:55:54 UTC (rev 24111)
+++ trunk/base/src/pextlib1.0/find.c	2007-04-17 00:06:48 UTC (rev 24112)
@@ -1,190 +0,0 @@
-/*
- * find.c
- * $Id$
- *
- * Find files and execute arbitrary expressions on them.
- * Author: Jordan K. Hubbard
- *
- * Copyright (c) 2004 Apple Computer, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#if HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#if HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-
-#if HAVE_DIRENT_H
-#include <dirent.h>
-#endif
-
-#if HAVE_LIMITS_H
-#include <limits.h>
-#endif
-
-#include <tcl.h>
-
-static int do_find(Tcl_Interp *interp, int flags, char *target, char *varname, char *body);
-
-#define F_DEPTH 0x1
-#define F_IGNORE_ERRORS 0x2
-
-/* find ?-depth? ?-ignoreErrors? varname target ?target ...? body */
-int
-FindCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
-{
-    char *varname;
-    char *body;
-    int flags = 0;
-    int rval = TCL_OK;
-    Tcl_Obj *CONST *objv_orig = objv;
-
-    /* Adjust arguments to remove initial `find' */
-    ++objv, --objc;
-
-    /* Parse flags */
-    while (objc) {
-        if (!strcmp(Tcl_GetString(*objv), "-depth")) {
-            flags |= F_DEPTH;
-            ++objv, --objc;
-            continue;
-        }
-        if (!strcmp(Tcl_GetString(*objv), "-ignoreErrors")) {
-            flags |= F_IGNORE_ERRORS;
-            ++objv, --objc;
-            continue;
-        }
-        break;
-    }
-    
-    /* Parse remaining args */
-    if (objc < 3) {
-        Tcl_WrongNumArgs(interp, 1, objv_orig, "?-depth? ?-ignoreErrors? varname target ?target target ...? body");
-        return TCL_ERROR;
-    }
-    
-    varname = Tcl_GetString(*objv);
-    ++objv, --objc;
-    
-    body = Tcl_GetString(objv[objc-1]);
-    --objc;
-    
-    while (objc) {
-        char *target = Tcl_GetString(*objv);
-        ++objv, --objc;
-        
-        if ((rval = do_find(interp, flags, target, varname, body)) == TCL_CONTINUE) {
-            rval = TCL_OK;
-            continue;
-        } else if (rval == TCL_BREAK) {
-            rval = TCL_OK;
-            break;
-        } else if (rval != TCL_OK) {
-            break;
-        }
-    }
-    return rval;
-}
-
-static int
-do_find(Tcl_Interp *interp, int flags, char *target, char *varname, char *body)
-{
-    DIR *dirp;
-    struct dirent *dp;
-    int rval = TCL_OK;
-    struct stat sb;
-    
-    /* No permission? */
-    if (lstat(target, &sb) != 0) {
-        if (flags & F_IGNORE_ERRORS) {
-            return TCL_OK;
-        } else {
-            Tcl_ResetResult(interp);
-            Tcl_AppendResult(interp, "Error: no permission to access file/folder `", target, "'");
-            return TCL_ERROR;
-        }
-    }
-    
-    /* Handle files now, or directories if !depth */
-    if (!(flags & F_DEPTH) || !(sb.st_mode & S_IFDIR)) {
-        Tcl_SetVar(interp, varname, target, 0);
-        if ((rval = Tcl_EvalEx(interp, body, -1, 0)) != TCL_OK) {
-            return rval;
-        }
-    }
-    
-    /* Handle directories */
-    if (sb.st_mode & S_IFDIR) {
-        if ((dirp = opendir(target)) == NULL) {
-            if (flags & F_IGNORE_ERRORS) {
-                return TCL_OK;
-            } else {
-                Tcl_ResetResult(interp);
-                Tcl_AppendResult(interp, "Error: Could not open directory `", target, "'");
-                return TCL_ERROR;
-            }
-        }
-        
-        while ((dp = readdir(dirp)) != NULL) {
-            char tmp_path[PATH_MAX];
-
-            if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, ".."))
-                continue;
-            strcpy(tmp_path, target);
-            strcat(tmp_path, "/");
-            strcat(tmp_path, dp->d_name);
-
-            if ((rval = do_find(interp, flags, tmp_path, varname, body)) == TCL_CONTINUE) {
-                rval = TCL_OK;
-                continue;
-            } else if (rval != TCL_OK) {
-                break;
-            }
-        }
-        (void)closedir(dirp);
-        
-        /* Handle directory now if depth */
-        if (flags & F_DEPTH) {
-            Tcl_SetVar(interp, varname, target, 0);
-            if ((rval = Tcl_EvalEx(interp, body, -1, 0)) != TCL_OK) {
-                return rval;
-            }
-        }
-    }
-    return rval;
-}

Deleted: trunk/base/src/pextlib1.0/find.h
===================================================================
--- trunk/base/src/pextlib1.0/find.h	2007-04-16 23:55:54 UTC (rev 24111)
+++ trunk/base/src/pextlib1.0/find.h	2007-04-17 00:06:48 UTC (rev 24112)
@@ -1,33 +0,0 @@
-/*
- * find.h
- * $Id$
- *
- * Copyright (c) 2002 - 2003 Apple Computer, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-int FindCmd(ClientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]);

Copied: trunk/base/src/pextlib1.0/fs-traverse.c (from rev 24110, trunk/base/src/pextlib1.0/find.c)
===================================================================
--- trunk/base/src/pextlib1.0/fs-traverse.c	                        (rev 0)
+++ trunk/base/src/pextlib1.0/fs-traverse.c	2007-04-17 00:06:48 UTC (rev 24112)
@@ -0,0 +1,190 @@
+/*
+ * fs-traverse.c
+ * $Id$
+ *
+ * Find files and execute arbitrary expressions on them.
+ * Author: Jordan K. Hubbard, Kevin Ballard
+ *
+ * Copyright (c) 2004 Apple Computer, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#if HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+#if HAVE_DIRENT_H
+#include <dirent.h>
+#endif
+
+#if HAVE_LIMITS_H
+#include <limits.h>
+#endif
+
+#include <tcl.h>
+
+static int do_traverse(Tcl_Interp *interp, int flags, char *target, char *varname, char *body);
+
+#define F_DEPTH 0x1
+#define F_IGNORE_ERRORS 0x2
+
+/* fs-traverse ?-depth? ?-ignoreErrors? varname target ?target ...? body */
+int
+FsTraverseCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
+{
+    char *varname;
+    char *body;
+    int flags = 0;
+    int rval = TCL_OK;
+    Tcl_Obj *CONST *objv_orig = objv;
+
+    /* Adjust arguments to remove initial `find' */
+    ++objv, --objc;
+
+    /* Parse flags */
+    while (objc) {
+        if (!strcmp(Tcl_GetString(*objv), "-depth")) {
+            flags |= F_DEPTH;
+            ++objv, --objc;
+            continue;
+        }
+        if (!strcmp(Tcl_GetString(*objv), "-ignoreErrors")) {
+            flags |= F_IGNORE_ERRORS;
+            ++objv, --objc;
+            continue;
+        }
+        break;
+    }
+    
+    /* Parse remaining args */
+    if (objc < 3) {
+        Tcl_WrongNumArgs(interp, 1, objv_orig, "?-depth? ?-ignoreErrors? varname target ?target target ...? body");
+        return TCL_ERROR;
+    }
+    
+    varname = Tcl_GetString(*objv);
+    ++objv, --objc;
+    
+    body = Tcl_GetString(objv[objc-1]);
+    --objc;
+    
+    while (objc) {
+        char *target = Tcl_GetString(*objv);
+        ++objv, --objc;
+        
+        if ((rval = do_traverse(interp, flags, target, varname, body)) == TCL_CONTINUE) {
+            rval = TCL_OK;
+            continue;
+        } else if (rval == TCL_BREAK) {
+            rval = TCL_OK;
+            break;
+        } else if (rval != TCL_OK) {
+            break;
+        }
+    }
+    return rval;
+}
+
+static int
+do_traverse(Tcl_Interp *interp, int flags, char *target, char *varname, char *body)
+{
+    DIR *dirp;
+    struct dirent *dp;
+    int rval = TCL_OK;
+    struct stat sb;
+    
+    /* No permission? */
+    if (lstat(target, &sb) != 0) {
+        if (flags & F_IGNORE_ERRORS) {
+            return TCL_OK;
+        } else {
+            Tcl_ResetResult(interp);
+            Tcl_AppendResult(interp, "Error: no permission to access file/folder `", target, "'");
+            return TCL_ERROR;
+        }
+    }
+    
+    /* Handle files now, or directories if !depth */
+    if (!(flags & F_DEPTH) || !(sb.st_mode & S_IFDIR)) {
+        Tcl_SetVar(interp, varname, target, 0);
+        if ((rval = Tcl_EvalEx(interp, body, -1, 0)) != TCL_OK) {
+            return rval;
+        }
+    }
+    
+    /* Handle directories */
+    if (sb.st_mode & S_IFDIR) {
+        if ((dirp = opendir(target)) == NULL) {
+            if (flags & F_IGNORE_ERRORS) {
+                return TCL_OK;
+            } else {
+                Tcl_ResetResult(interp);
+                Tcl_AppendResult(interp, "Error: Could not open directory `", target, "'");
+                return TCL_ERROR;
+            }
+        }
+        
+        while ((dp = readdir(dirp)) != NULL) {
+            char tmp_path[PATH_MAX];
+
+            if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, ".."))
+                continue;
+            strcpy(tmp_path, target);
+            strcat(tmp_path, "/");
+            strcat(tmp_path, dp->d_name);
+
+            if ((rval = do_traverse(interp, flags, tmp_path, varname, body)) == TCL_CONTINUE) {
+                rval = TCL_OK;
+                continue;
+            } else if (rval != TCL_OK) {
+                break;
+            }
+        }
+        (void)closedir(dirp);
+        
+        /* Handle directory now if depth */
+        if (flags & F_DEPTH) {
+            Tcl_SetVar(interp, varname, target, 0);
+            if ((rval = Tcl_EvalEx(interp, body, -1, 0)) != TCL_OK) {
+                return rval;
+            }
+        }
+    }
+    return rval;
+}

Copied: trunk/base/src/pextlib1.0/fs-traverse.h (from rev 24110, trunk/base/src/pextlib1.0/find.h)
===================================================================
--- trunk/base/src/pextlib1.0/fs-traverse.h	                        (rev 0)
+++ trunk/base/src/pextlib1.0/fs-traverse.h	2007-04-17 00:06:48 UTC (rev 24112)
@@ -0,0 +1,33 @@
+/*
+ * fs-traverse.h
+ * $Id$
+ *
+ * Copyright (c) 2002 - 2003 Apple Computer, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+int FsTraverseCmd(ClientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]);

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20070416/10a027a8/attachment.html


More information about the macports-changes mailing list