[24410] trunk/base
source_changes at macosforge.org
source_changes at macosforge.org
Mon Apr 23 22:37:53 PDT 2007
Revision: 24410
http://trac.macosforge.org/projects/macports/changeset/24410
Author: eridius at macports.org
Date: 2007-04-23 22:37:52 -0700 (Mon, 23 Apr 2007)
Log Message:
-----------
fs-traverse now takes a list of targets rather than a variable number of arguments.
Update the new tests to match this new behaviour.
Update portfile.7 documentation.
Closes #11836.
Modified Paths:
--------------
trunk/base/doc/portfile.7
trunk/base/src/pextlib1.0/fs-traverse.c
trunk/base/src/pextlib1.0/tests/fs-traverse.tcl
Modified: trunk/base/doc/portfile.7
===================================================================
--- trunk/base/doc/portfile.7 2007-04-24 05:35:54 UTC (rev 24409)
+++ trunk/base/doc/portfile.7 2007-04-24 05:37:52 UTC (rev 24410)
@@ -1486,17 +1486,16 @@
.Op Fl depth
.Op Fl ignoreErrors
.Ar varname
-.Ar target
-.Op Ar target ...
+.Ar target-list
.Ar body
.Xc
-Traverse the filesystem hierarchy rooted in each
-.Ar target
+Traverse the filesystem hierarchy rooted in each element of
+.Ar target-list
and execute
.Ar body
-for each found file/directory. Sets
+for each found file/directory.
.Ar varname
-to the path of the file/directory. If
+is set to the path of the file/directory. If
.Nm break
is called during execution, the filesystem traversal is stopped. If
.Nm continue
Modified: trunk/base/src/pextlib1.0/fs-traverse.c
===================================================================
--- trunk/base/src/pextlib1.0/fs-traverse.c 2007-04-24 05:35:54 UTC (rev 24409)
+++ trunk/base/src/pextlib1.0/fs-traverse.c 2007-04-24 05:37:52 UTC (rev 24410)
@@ -64,7 +64,7 @@
#define F_DEPTH 0x1
#define F_IGNORE_ERRORS 0x2
-/* fs-traverse ?-depth? ?-ignoreErrors? varname target ?target ...? body */
+/* fs-traverse ?-depth? ?-ignoreErrors? varname target-list body */
int
FsTraverseCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
{
@@ -72,7 +72,10 @@
char *body;
int flags = 0;
int rval = TCL_OK;
+ Tcl_Obj *listPtr;
Tcl_Obj *CONST *objv_orig = objv;
+ int lobjc;
+ Tcl_Obj **lobjv;
/* Adjust arguments to remove initial `find' */
++objv, --objc;
@@ -93,29 +96,33 @@
}
/* Parse remaining args */
- if (objc < 3) {
- Tcl_WrongNumArgs(interp, 1, objv_orig, "?-depth? ?-ignoreErrors? varname target ?target target ...? body");
+ if (objc != 3) {
+ Tcl_WrongNumArgs(interp, 1, objv_orig, "?-depth? ?-ignoreErrors? varname target-list body");
return TCL_ERROR;
}
varname = Tcl_GetString(*objv);
++objv, --objc;
- body = Tcl_GetString(objv[objc-1]);
- --objc;
+ listPtr = *objv;
+ ++objv, --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;
+ body = Tcl_GetString(*objv);
+
+ if ((rval = Tcl_ListObjGetElements(interp, listPtr, &lobjc, &lobjv)) == TCL_OK) {
+ while (lobjc) {
+ char *target = Tcl_GetString(*lobjv);
+ ++lobjv, --lobjc;
+
+ 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;
@@ -135,7 +142,7 @@
return TCL_OK;
} else {
Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "Error: no permission to access file/folder `", target, "'", NULL);
+ Tcl_AppendResult(interp, "no permission to access file/folder `", target, "'", NULL);
return TCL_ERROR;
}
}
@@ -155,7 +162,7 @@
return TCL_OK;
} else {
Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "Error: Could not open directory `", target, "'", NULL);
+ Tcl_AppendResult(interp, "could not open directory `", target, "'", NULL);
return TCL_ERROR;
}
}
Modified: trunk/base/src/pextlib1.0/tests/fs-traverse.tcl
===================================================================
--- trunk/base/src/pextlib1.0/tests/fs-traverse.tcl 2007-04-24 05:35:54 UTC (rev 24409)
+++ trunk/base/src/pextlib1.0/tests/fs-traverse.tcl 2007-04-24 05:37:52 UTC (rev 24410)
@@ -35,14 +35,14 @@
# Test multiple sources
set output [list]
- fs-traverse file $root/a $root/b {
+ fs-traverse file [list $root/a $root/b] {
lappend output $file
}
check_output $output $tree3
# Test multiple sources with -depth
set output [list]
- fs-traverse -depth file $root/a $root/b {
+ fs-traverse -depth file [list $root/a $root/b] {
lappend output $file
}
check_output $output $tree4
@@ -60,7 +60,7 @@
# Test -ignoreErrors with multiple sources, make sure it still gets the sources after the error
if {[catch {
set output [list]
- fs-traverse -depth -ignoreErrors file $root/a $root/c $root/b {
+ fs-traverse -depth -ignoreErrors file [list $root/a $root/c $root/b] {
lappend output $file
}
check_output $output $tree4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20070423/2af652e6/attachment.html
More information about the macports-changes
mailing list