Stefan,
>
> > Would you be interested in a patch for this?
>
> Off course.
>
OK, here's the patch.
I suppose that it's OK to use the collection framework, now that Ant 1.6 will require Java 1.2. I've used HashMap and Iterator in the patch, but it should be easy to change to Hashtable.
The <property> task description contains a OpenVMS specific note.
Cheers,
--
knut
Index: docs/manual/CoreTasks/property.html =================================================================== RCS file: /home/cvspublic/ant/docs/manual/CoreTasks/property.html,v retrieving revision 1.15 diff -u -r1.15 property.html --- docs/manual/CoreTasks/property.html 18 Jun 2003 08:10:21 -0000 1.15 +++ docs/manual/CoreTasks/property.html 25 Jul 2003 11:59:00 -0000 @@ -38,6 +38,16 @@ This also holds for properties loaded from a property file.</p> <p>A list of predefined properties can be found <a href="../using.html#built-in-props">here</a>.</p> + +<h4>OpenVMS Users</h4> +<p>With the <code>environment</code> attribute this task will load all defined +logicals on an OpenVMS system. Logicals with multiple equivalence names get +mapped to a property whose value is a comma separated list of all equivalence +names. If a logical is defined in multiple tables, only the most local +definition is available (the table priority order being PROCESS, JOB, GROUP, +SYSTEM). +</p> + <h3>Parameters</h3> <table border="1" cellpadding="2" cellspacing="0"> <tr> Index: src/main/org/apache/tools/ant/taskdefs/Execute.java =================================================================== RCS file: /home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/Execute.java,v retrieving revision 1.58 diff -u -r1.58 Execute.java --- src/main/org/apache/tools/ant/taskdefs/Execute.java 25 Jul 2003 10:06:32 -0000 1.58 +++ src/main/org/apache/tools/ant/taskdefs/Execute.java 25 Jul 2003 11:59:07 -0000 @@ -63,6 +63,8 @@ import java.io.StringReader; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Iterator; import java.util.Vector; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; @@ -192,6 +194,11 @@ BufferedReader in = new BufferedReader(new StringReader(toString(out))); + if (Os.isFamily("openvms")) { + procEnvironment = addVMSLogicals(procEnvironment, in); + return procEnvironment; + } + String var = null; String line, lineSep = System.getProperty("line.separator"); while ((line = in.readLine()) != null) { @@ -266,6 +273,58 @@ return cmd; } } + + /** + * This method is VMS specific and used by getProcEnvironment(). + * + * Parses VMS logicals from <code>in</code> and adds them to + * <code>environment</code>. <code>in</code> is expected to be the + * output of "SHOW LOGICAL". The method takes care of parsing the output + * correctly as well as making sure that a logical defined in multiple + * tables only gets added from the highest order table. Logicals with + * multiple equivalence names are mapped to a variable with multiple + * values separated by a comma (,). + */ + private static Vector addVMSLogicals(Vector environment, BufferedReader in) + throws IOException { + HashMap logicals = new HashMap(); + + String logName = null, logValue = null, newLogName; + String line, lineSep = System.getProperty("line.separator"); + while ((line = in.readLine()) != null) { + // parse the VMS logicals into required format ("VAR=VAL[,VAL2]") + if (line.startsWith("\t=")) { + // further equivalence name of previous logical + if (logName != null) { + logValue += "," + line.substring(4, line.length() - 1); + } + } else if (line.startsWith(" \"")) { + // new logical? + if (logName != null) { + logicals.put(logName, logValue); + } + int eqIndex = line.indexOf('='); + newLogName = line.substring(3, eqIndex - 2); + if (logicals.containsKey(newLogName)) { + // already got this logical from a higher order table + logName = null; + } else { + logName = newLogName; + logValue = line.substring(eqIndex + 3, line.length() - 1); + } + } + } + // Since we "look ahead" before adding, there's one last env var. + if (logName != null) { + logicals.put(logName, logValue); + } + + for (Iterator i = logicals.keySet().iterator(); i.hasNext();) { + String logical = (String) i.next(); + environment.add(logical + "=" + logicals.get(logical)); + } + return environment; + } /** * ByteArrayOutputStream#toString doesn't seem to work reliably on
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]