2) Correct Stefano's mailing address 3) Correct handling of escaped quotes in strings 4) Return exit code from the exec'd process as it may be useful Submitted by: Michael Smith <michael@sneakerlabs.com> git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267590 13f79535-47bb-0310-9956-ffa450edef68master
@@ -76,7 +76,9 @@ public class Exec extends Task { | |||||
run(command); | run(command); | ||||
} | } | ||||
protected void run(String command) throws BuildException { | |||||
protected int run(String command) throws BuildException { | |||||
int err = -1; // assume the worst | |||||
// test if os match | // test if os match | ||||
String myos = System.getProperty("os.name"); | String myos = System.getProperty("os.name"); | ||||
@@ -84,7 +86,7 @@ public class Exec extends Task { | |||||
if ((os != null) && (os.indexOf(myos) < 0)){ | if ((os != null) && (os.indexOf(myos) < 0)){ | ||||
// this command will be executed only on the specified OS | // this command will be executed only on the specified OS | ||||
project.log("Not found in " + os, Project.MSG_VERBOSE); | project.log("Not found in " + os, Project.MSG_VERBOSE); | ||||
return; | |||||
return 0; | |||||
} | } | ||||
if (myos.toLowerCase().indexOf("windows") >= 0) { | if (myos.toLowerCase().indexOf("windows") >= 0) { | ||||
@@ -131,13 +133,15 @@ public class Exec extends Task { | |||||
if (fos != null) fos.close(); | if (fos != null) fos.close(); | ||||
// check its exit value | // check its exit value | ||||
int err = proc.exitValue(); | |||||
err = proc.exitValue(); | |||||
if (err != 0) { | if (err != 0) { | ||||
project.log("Result: " + err, "exec", Project.MSG_ERR); | project.log("Result: " + err, "exec", Project.MSG_ERR); | ||||
} | } | ||||
} catch (IOException ioe) { | } catch (IOException ioe) { | ||||
throw new BuildException("Error exec: " + command ); | throw new BuildException("Error exec: " + command ); | ||||
} catch (InterruptedException ex) {} | } catch (InterruptedException ex) {} | ||||
return err; | |||||
} | } | ||||
public void setDir(String d) { | public void setDir(String d) { | ||||
@@ -74,7 +74,7 @@ import java.util.*; | |||||
* System.exit() that would break Ant functionality. | * System.exit() that would break Ant functionality. | ||||
* | * | ||||
* @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a> | * @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a> | ||||
* @author Stefano Mazzocchi <a href="mailto:stefano@pache.org">stefano@apache.org</a> | |||||
* @author Stefano Mazzocchi <a href="mailto:stefano@apache.org">stefano@apache.org</a> | |||||
*/ | */ | ||||
public class Javadoc extends Exec { | public class Javadoc extends Exec { | ||||
@@ -571,9 +571,9 @@ public class Javadoc extends Exec { | |||||
if (c == '/') { | if (c == '/') { | ||||
c = in.read(); | c = in.read(); | ||||
if (c == '/') { | if (c == '/') { | ||||
while (c != '\n') c = in.read(); | |||||
while (c != '\n' && c != -1) c = in.read(); | |||||
} else if (c == '*') { | } else if (c == '*') { | ||||
while (true) { | |||||
while (c != -1) { | |||||
c = in.read(); | c = in.read(); | ||||
if (c == '*') { | if (c == '*') { | ||||
c = in.read(); | c = in.read(); | ||||
@@ -586,10 +586,11 @@ public class Javadoc extends Exec { | |||||
} | } | ||||
} | } | ||||
if (c == '"') { | if (c == '"') { | ||||
while (true) { | |||||
while (c != -1) { | |||||
c = in.read(); | c = in.read(); | ||||
if (c == '\\') c = in.read(); | |||||
if (c == '"') { | |||||
if (c == '\\') { | |||||
c = in.read(); | |||||
} else if (c == '"') { | |||||
c = read(); | c = read(); | ||||
break; | break; | ||||
} | } | ||||