From d950f9fab8811e2f3b2e022ba2955b0e3d2b88ba Mon Sep 17 00:00:00 2001 From: johncurrier Date: Sat, 7 Oct 2006 05:49:27 +0000 Subject: [PATCH] Bug 1571711 - can't detect dot version on MacOS-X --- src/net/sourceforge/schemaspy/util/Dot.java | 24 +++++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/net/sourceforge/schemaspy/util/Dot.java b/src/net/sourceforge/schemaspy/util/Dot.java index bfa6d5e..de6a5a3 100755 --- a/src/net/sourceforge/schemaspy/util/Dot.java +++ b/src/net/sourceforge/schemaspy/util/Dot.java @@ -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:"); @@ -28,7 +38,7 @@ private Dot() { } catch (Exception validDotDoesntExist) { } - version = new Version(tempVersion); + version = new Version(found); } public static Dot getInstance() { @@ -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); } } @@ -162,4 +172,4 @@ public void run() { } } } -} +} \ No newline at end of file