diff options
author | Per Bothner <per@bothner.com> | 2017-09-01 09:53:38 -0700 |
---|---|---|
committer | Per Bothner <per@bothner.com> | 2017-09-01 09:53:38 -0700 |
commit | 8b590b607bb65cc1e3d5d0e31e177fa5aa6a39e5 (patch) | |
tree | c97099db335e538f866c1f6ae40afe0e87578eb7 | |
parent | 0ac6a0782f4df3a75f16a1d0c38ce1a3e8457764 (diff) |
* repl.java (browseManual): rap with #ifdef for httpserver.18-fix-xquery-check-format-users-test-on-openbsd
This is to avoid link problems when the HttpServer is missing.
-rw-r--r-- | kawa/ChangeLog | 5 | ||||
-rw-r--r-- | kawa/repl.java | 39 |
2 files changed, 32 insertions, 12 deletions
diff --git a/kawa/ChangeLog b/kawa/ChangeLog index d72ffb2e8..86b7b80d7 100644 --- a/kawa/ChangeLog +++ b/kawa/ChangeLog @@ -1,3 +1,8 @@ +2017-09-01 Per Bothner <per@bothner.com> + + * repl.java (browseManual): rap with #ifdef for httpserver. + This is to avoid link problems when the HttpServer is missing. + 2017-08-31 Per Bothner <per@bothner.com> * ImportFromLibrary.java: Add classname mangling. diff --git a/kawa/repl.java b/kawa/repl.java index 076860f5b..848fe543b 100644 --- a/kawa/repl.java +++ b/kawa/repl.java @@ -910,8 +910,19 @@ public class repl extends Procedure0or1 { File manualFile = new File(kawaHome+"/doc/kawa-manual.epub"); if (! manualFile.exists()) return manualFile+" does not exist"; - if (browserCommand == null || browserCommand.length() == 0) - browserCommand = "browser"; + if (browserCommand == null || browserCommand.length() == 0) { + try { + Class.forName("gnu.kawa.servlet.KawaHttpHandler"); + browserCommand = "browser"; + } catch (Throwable ex1) { + try { + Class.forName("gnu.kawa.javafx.KawaJavafxApplication"); + browserCommand = "javafx"; + } catch (Throwable ex2) { + return "don't know how to display manual (neither JavaFX or HttpServer classes found)"; + } + } + } if (browserCommand.equals("javafx")) { // FIXME ignores 'path' argument String filename = kawaHome+"/doc/browse-kawa-manual"; @@ -919,6 +930,7 @@ public class repl extends Procedure0or1 { Shell.runFileOrClass(filename, false, 0); return null; } + /* #ifdef use:com.sun.net.httpserver */ String defaultUrl = "index.html"; String pathPrefix = "jar:file:" + manualFile + "!/OEBPS"; gnu.kawa.servlet.KawaHttpHandler.addStaticFileHandler("/kawa-manual/", @@ -932,21 +944,24 @@ public class repl extends Procedure0or1 { String webUrl = "http://127.0.0.1:"+htport+"/kawa-manual/" + path; if (browserCommand.equals("google-chrome")) browserCommand = "google-chrome --app=%U"; - if (browserCommand.equals("browser")) { + if (browserCommand.equals("browser")) { if (! Desktop.isDesktopSupported()) return "using default desktop browser not supported"; Desktop.getDesktop().browse(new URI(webUrl)); return null; - } else { - if (browserCommand.indexOf('%') < 0) - browserCommand = browserCommand + " %U"; - try { - Runtime.getRuntime().exec(browserCommand.replace("%U", webUrl)); - } catch (Throwable ex) { - return "cannot read manual (using command: "+browserCommand+")"; - } - return null; + } else { + if (browserCommand.indexOf('%') < 0) + browserCommand = browserCommand + " %U"; + try { + Runtime.getRuntime().exec(browserCommand.replace("%U", webUrl)); + } catch (Throwable ex) { + return "cannot read manual (using command: "+browserCommand+")"; + } + return null; } + /* #else */ + // return "cannot read manual using builin http server"; + /* #endif */ } catch (Throwable ex) { return "caught exception "+ex.toString(); } |