Skip to content

Commit

Permalink
Bug 1571711 - can't detect dot version on MacOS-X
Browse files Browse the repository at this point in the history
  • Loading branch information
johncurrier committed Oct 7, 2006
1 parent 8bc5983 commit d950f9f
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/net/sourceforge/schemaspy/util/Dot.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,26 @@ public class Dot {
private final Version badVersion = new Version("2.4");

private Dot() {
String tempVersion = null;
String found = null;
try {
// dot -V should return something similar to:
// dot version 2.8 (Fri Feb 3 22:38:53 UTC 2006)
// or sometimes something like:
// dot - Graphviz version 2.9.20061004.0440 (Wed Oct 4 21:01:52 GMT 2006)
String dotCommand = "dot -V";
Process process = Runtime.getRuntime().exec(dotCommand);
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
String versionLine = reader.readLine();
StringTokenizer tokenizer = new StringTokenizer(versionLine);
if (tokenizer.nextToken().equals("dot")) { // skip 'dot'
tokenizer.nextToken(); // skip 'version'
tempVersion = tokenizer.nextToken(); // x.x.x
// search for numeric portion of dot's output
while (found == null) {
// Jean-François Veillette provides this logic:
String token = tokenizer.nextToken(); // skip 'version'
if (token.matches("[0-9.]*")) {
found = token; // found numeric portion
}
}
} else {
System.err.println();
System.err.println("Invalid dot configuration detected. '" + dotCommand + "' returned:");
Expand All @@ -28,7 +38,7 @@ private Dot() {
} catch (Exception validDotDoesntExist) {
}

version = new Version(tempVersion);
version = new Version(found);
}

public static Dot getInstance() {
Expand Down Expand Up @@ -116,9 +126,9 @@ public void writeMap(File dotFile, LineWriter out) throws DotFailure {
}

public class DotFailure extends IOException {
private static final long serialVersionUID = 3833743270181351987L;
private static final long serialVersionUID = 3833743270181351987L;

public DotFailure(String msg) {
public DotFailure(String msg) {
super(msg);
}
}
Expand Down Expand Up @@ -162,4 +172,4 @@ public void run() {
}
}
}
}
}

0 comments on commit d950f9f

Please sign in to comment.