jruby-launcher 1.1.1-java → 1.1.2-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,81 +1,81 @@
1
- require 'rspec'
2
- require 'rbconfig'
3
- require 'fileutils'
4
-
5
- if defined?(JRUBY_VERSION)
6
- require 'jruby'
7
- JRuby.runtime.instance_config.run_ruby_in_process = false
8
- end
9
-
10
- module JRubyLauncherHelper
11
- JRUBY_EXE = ''
12
- WINDOWS = RbConfig::CONFIG['target_os'] =~ /mswin/
13
-
14
- def self.check_executable_built
15
- exe = File.expand_path("../../jruby", __FILE__) + RbConfig::CONFIG['EXEEXT']
16
- unless File.executable?(exe)
17
- raise "Error: launcher executable not built; type `make' before continuing."
18
- end
19
- top = File.dirname(exe)
20
- name = File.basename(exe)
21
- home = File.join(top, "build/home")
22
- FileUtils.mkdir_p(File.join(home, "bin"))
23
- FileUtils.cp(exe, File.join(home, "bin"))
24
- if JRubyLauncherHelper::WINDOWS
25
- FileUtils.cp(exe.sub(/exe/, 'dll'), File.join(home, "bin"))
26
- end
27
- FileUtils.mkdir_p(File.join(home, "lib"))
28
- FileUtils.touch(File.join(home, "lib/jruby.jar"))
29
- JRUBY_EXE.concat File.join(home, "bin", name)
30
- end
31
-
32
- def jruby_launcher(args)
33
- `#{JRUBY_EXE} #{args}`
34
- end
35
-
36
- def jruby_launcher_args(args)
37
- jruby_launcher("-Xcommand #{args}").split("\n")
38
- end
39
-
40
- def last_exit_code
41
- $?.exitstatus
42
- end
43
-
44
- def windows?
45
- WINDOWS
46
- end
47
-
48
- def classpath_arg(args)
49
- index = args.index("-cp")
50
- index.should > 0
51
- args[index + 1]
52
- end
53
-
54
- def with_environment(pairs = {})
55
- prev_env = {}
56
- pairs.each_pair do |k,v|
57
- prev_env[k] = ENV[k] if ENV.has_key?(k)
58
- ENV[k] = v
59
- end
60
- begin
61
- yield
62
- ensure
63
- pairs.keys.each {|k| ENV.delete(k)}
64
- ENV.update(prev_env)
65
- end
66
- end
67
- end
68
-
69
- RSpec.configure do |config|
70
- config.before(:all) do
71
- JRubyLauncherHelper.check_executable_built
72
- # clear environment for better control
73
- ENV.delete("JAVA_HOME")
74
- ENV.delete("JRUBY_HOME")
75
- ENV.delete("JAVA_OPTS")
76
- ENV.delete("JRUBY_OPTS")
77
- ENV.delete("CLASSPATH")
78
- ENV.delete("JAVA_ENCODING")
79
- end
80
- config.include(JRubyLauncherHelper)
81
- end
1
+ require 'rspec'
2
+ require 'rbconfig'
3
+ require 'fileutils'
4
+
5
+ if defined?(JRUBY_VERSION)
6
+ require 'jruby'
7
+ JRuby.runtime.instance_config.run_ruby_in_process = false
8
+ end
9
+
10
+ module JRubyLauncherHelper
11
+ JRUBY_EXE = ''
12
+ WINDOWS = RbConfig::CONFIG['target_os'] =~ /mswin/
13
+
14
+ def self.check_executable_built
15
+ exe = File.expand_path("../../jruby", __FILE__) + RbConfig::CONFIG['EXEEXT']
16
+ unless File.executable?(exe)
17
+ raise "Error: launcher executable not built; type `make' before continuing."
18
+ end
19
+ top = File.dirname(exe)
20
+ name = File.basename(exe)
21
+ home = File.join(top, "build/home")
22
+ FileUtils.mkdir_p(File.join(home, "bin"))
23
+ FileUtils.cp(exe, File.join(home, "bin"))
24
+ if JRubyLauncherHelper::WINDOWS
25
+ FileUtils.cp(exe.sub(/exe/, 'dll'), File.join(home, "bin"))
26
+ end
27
+ FileUtils.mkdir_p(File.join(home, "lib"))
28
+ FileUtils.touch(File.join(home, "lib/jruby.jar"))
29
+ JRUBY_EXE.concat File.join(home, "bin", name)
30
+ end
31
+
32
+ def jruby_launcher(args)
33
+ `#{JRUBY_EXE} #{args}`
34
+ end
35
+
36
+ def jruby_launcher_args(args)
37
+ jruby_launcher("-Xcommand #{args}").split("\n")
38
+ end
39
+
40
+ def last_exit_code
41
+ $?.exitstatus
42
+ end
43
+
44
+ def windows?
45
+ WINDOWS
46
+ end
47
+
48
+ def classpath_arg(args)
49
+ index = args.index("-cp")
50
+ index.should > 0
51
+ args[index + 1]
52
+ end
53
+
54
+ def with_environment(pairs = {})
55
+ prev_env = {}
56
+ pairs.each_pair do |k,v|
57
+ prev_env[k] = ENV[k] if ENV.has_key?(k)
58
+ ENV[k] = v
59
+ end
60
+ begin
61
+ yield
62
+ ensure
63
+ pairs.keys.each {|k| ENV.delete(k)}
64
+ ENV.update(prev_env)
65
+ end
66
+ end
67
+ end
68
+
69
+ RSpec.configure do |config|
70
+ config.before(:all) do
71
+ JRubyLauncherHelper.check_executable_built
72
+ # clear environment for better control
73
+ ENV.delete("JAVA_HOME")
74
+ ENV.delete("JRUBY_HOME")
75
+ ENV.delete("JAVA_OPTS")
76
+ ENV.delete("JRUBY_OPTS")
77
+ ENV.delete("CLASSPATH")
78
+ ENV.delete("JAVA_ENCODING")
79
+ end
80
+ config.include(JRubyLauncherHelper)
81
+ end
data/strlcpy.c CHANGED
@@ -1,72 +1,72 @@
1
- /* $OpenBSD: strlcpy.c,v 1.5 2001/05/13 15:40:16 deraadt Exp $ */
2
-
3
- /*
4
- * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
5
- * All rights reserved.
6
- *
7
- * Redistribution and use in source and binary forms, with or without
8
- * modification, are permitted provided that the following conditions
9
- * are met:
10
- * 1. Redistributions of source code must retain the above copyright
11
- * notice, this list of conditions and the following disclaimer.
12
- * 2. Redistributions in binary form must reproduce the above copyright
13
- * notice, this list of conditions and the following disclaimer in the
14
- * documentation and/or other materials provided with the distribution.
15
- * 3. The name of the author may not be used to endorse or promote products
16
- * derived from this software without specific prior written permission.
17
- *
18
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21
- * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
- */
29
-
30
- #if defined(LIBC_SCCS) && !defined(lint)
31
- static char *rcsid = "$OpenBSD: strlcpy.c,v 1.5 2001/05/13 15:40:16 deraadt Exp $";
32
- #endif /* LIBC_SCCS and not lint */
33
-
34
- #include <sys/types.h>
35
- #include <string.h>
36
-
37
- #ifdef strlcpy
38
- #undef strlcpy
39
- #endif
40
- /*
41
- * Copy src to string dst of size siz. At most siz-1 characters
42
- * will be copied. Always NUL terminates (unless siz == 0).
43
- * Returns strlen(src); if retval >= siz, truncation occurred.
44
- */
45
- size_t
46
- strlcpy(dst, src, siz)
47
- char *dst;
48
- const char *src;
49
- size_t siz;
50
- {
51
- register char *d = dst;
52
- register const char *s = src;
53
- register size_t n = siz;
54
-
55
- /* Copy as many bytes as will fit */
56
- if (n != 0 && --n != 0) {
57
- do {
58
- if ((*d++ = *s++) == 0)
59
- break;
60
- } while (--n != 0);
61
- }
62
-
63
- /* Not enough room in dst, add NUL and traverse rest of src */
64
- if (n == 0) {
65
- if (siz != 0)
66
- *d = '\0'; /* NUL-terminate dst */
67
- while (*s++)
68
- ;
69
- }
70
-
71
- return(s - src - 1); /* count does not include NUL */
72
- }
1
+ /* $OpenBSD: strlcpy.c,v 1.5 2001/05/13 15:40:16 deraadt Exp $ */
2
+
3
+ /*
4
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions
9
+ * are met:
10
+ * 1. Redistributions of source code must retain the above copyright
11
+ * notice, this list of conditions and the following disclaimer.
12
+ * 2. Redistributions in binary form must reproduce the above copyright
13
+ * notice, this list of conditions and the following disclaimer in the
14
+ * documentation and/or other materials provided with the distribution.
15
+ * 3. The name of the author may not be used to endorse or promote products
16
+ * derived from this software without specific prior written permission.
17
+ *
18
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21
+ * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+ */
29
+
30
+ #if defined(LIBC_SCCS) && !defined(lint)
31
+ static char *rcsid = "$OpenBSD: strlcpy.c,v 1.5 2001/05/13 15:40:16 deraadt Exp $";
32
+ #endif /* LIBC_SCCS and not lint */
33
+
34
+ #include <sys/types.h>
35
+ #include <string.h>
36
+
37
+ #ifdef strlcpy
38
+ #undef strlcpy
39
+ #endif
40
+ /*
41
+ * Copy src to string dst of size siz. At most siz-1 characters
42
+ * will be copied. Always NUL terminates (unless siz == 0).
43
+ * Returns strlen(src); if retval >= siz, truncation occurred.
44
+ */
45
+ size_t
46
+ strlcpy(dst, src, siz)
47
+ char *dst;
48
+ const char *src;
49
+ size_t siz;
50
+ {
51
+ register char *d = dst;
52
+ register const char *s = src;
53
+ register size_t n = siz;
54
+
55
+ /* Copy as many bytes as will fit */
56
+ if (n != 0 && --n != 0) {
57
+ do {
58
+ if ((*d++ = *s++) == 0)
59
+ break;
60
+ } while (--n != 0);
61
+ }
62
+
63
+ /* Not enough room in dst, add NUL and traverse rest of src */
64
+ if (n == 0) {
65
+ if (siz != 0)
66
+ *d = '\0'; /* NUL-terminate dst */
67
+ while (*s++)
68
+ ;
69
+ }
70
+
71
+ return(s - src - 1); /* count does not include NUL */
72
+ }
@@ -1,100 +1,100 @@
1
- #include <stdlib.h>
2
- #include <unistd.h>
3
- #include "unixlauncher.h"
4
- #include "utilsfuncs.h"
5
-
6
- using namespace std;
7
-
8
- extern "C" int nailgunClientMain(int argc, char *argv[], char *env[]);
9
-
10
- UnixLauncher::UnixLauncher()
11
- : ArgParser()
12
- {
13
- }
14
-
15
- UnixLauncher::UnixLauncher(const UnixLauncher& orig)
16
- : ArgParser(orig)
17
- {
18
- }
19
-
20
- UnixLauncher::~UnixLauncher() {
21
- }
22
-
23
- int UnixLauncher::run(int argc, char* argv[], char* envp[]) {
24
- platformDir = argv[0];
25
- if (!initPlatformDir() || !parseArgs(argc - 1, argv + 1)) {
26
- return 255;
27
- }
28
-
29
- if (nailgunClient) {
30
- progArgs.push_front("org.jruby.util.NailMain");
31
- char ** nailArgv = convertToArgvArray(progArgs);
32
- int nailArgc = progArgs.size();
33
-
34
- if (printCommandLine) {
35
- printListToConsole(progArgs);
36
- for (int i = 0; i < nailArgc; i++) {
37
- free(nailArgv[i]);
38
- }
39
- delete[] nailArgv;
40
- return 0;
41
- }
42
- return nailgunClientMain(progArgs.size(), (char**)nailArgv, envp);
43
- }
44
-
45
- prepareOptions();
46
-
47
- string java("");
48
-
49
- if (getenv("JAVACMD") != NULL) {
50
- java = getenv("JAVACMD");
51
- } else {
52
- if (!jdkhome.empty()) {
53
- java = jdkhome + "/bin/java";
54
- } else if (getenv("JAVA_HOME") != NULL) {
55
- string java_home = string(getenv("JAVA_HOME"));
56
- java_home = trimTrailingBackslashes(java_home);
57
- java = java_home + "/bin/java";
58
- } else {
59
- java = findOnPath("java");
60
- }
61
- }
62
-
63
- if (java.empty()) {
64
- printToConsole("No `java' executable found on PATH.");
65
- return 255;
66
- }
67
-
68
- list<string> commandLine;
69
- commandLine.push_back(java);
70
- addOptionsToCommandLine(commandLine);
71
-
72
- logMsg("Command line:");
73
- for (list<string>::iterator it = commandLine.begin(); it != commandLine.end(); ++it) {
74
- logMsg(it->c_str());
75
- }
76
-
77
- char** newArgv = convertToArgvArray(commandLine);
78
- int newArgc = commandLine.size();
79
-
80
- if (printCommandLine) {
81
- printListToConsole(commandLine);
82
- for (int i = 0; i < newArgc; i++) {
83
- free(newArgv[i]);
84
- }
85
- delete[] newArgv;
86
- return 0;
87
- }
88
-
89
- if (!fileExists(java.c_str())) {
90
- string msg = "No `java' exists at " + java + ", please double-check JAVA_HOME.\n";
91
- printToConsole(msg.c_str());
92
- return 255;
93
- }
94
-
95
- execv(java.c_str(), newArgv);
96
-
97
- // shouldn't get here unless something bad happened with execv
98
- logErr(true, true, "execv failed:");
99
- return 255;
100
- }
1
+ #include <stdlib.h>
2
+ #include <unistd.h>
3
+ #include "unixlauncher.h"
4
+ #include "utilsfuncs.h"
5
+
6
+ using namespace std;
7
+
8
+ extern "C" int nailgunClientMain(int argc, char *argv[], char *env[]);
9
+
10
+ UnixLauncher::UnixLauncher()
11
+ : ArgParser()
12
+ {
13
+ }
14
+
15
+ UnixLauncher::UnixLauncher(const UnixLauncher& orig)
16
+ : ArgParser(orig)
17
+ {
18
+ }
19
+
20
+ UnixLauncher::~UnixLauncher() {
21
+ }
22
+
23
+ int UnixLauncher::run(int argc, char* argv[], char* envp[]) {
24
+ platformDir = argv[0];
25
+ if (!initPlatformDir() || !parseArgs(argc - 1, argv + 1)) {
26
+ return 255;
27
+ }
28
+
29
+ if (nailgunClient) {
30
+ progArgs.push_front("org.jruby.util.NailMain");
31
+ char ** nailArgv = convertToArgvArray(progArgs);
32
+ int nailArgc = progArgs.size();
33
+
34
+ if (printCommandLine) {
35
+ printListToConsole(progArgs);
36
+ for (int i = 0; i < nailArgc; i++) {
37
+ free(nailArgv[i]);
38
+ }
39
+ delete[] nailArgv;
40
+ return 0;
41
+ }
42
+ return nailgunClientMain(progArgs.size(), (char**)nailArgv, envp);
43
+ }
44
+
45
+ prepareOptions();
46
+
47
+ string java("");
48
+
49
+ if (getenv("JAVACMD") != NULL) {
50
+ java = getenv("JAVACMD");
51
+ } else {
52
+ if (!jdkhome.empty()) {
53
+ java = jdkhome + "/bin/java";
54
+ } else if (getenv("JAVA_HOME") != NULL) {
55
+ string java_home = string(getenv("JAVA_HOME"));
56
+ java_home = trimTrailingBackslashes(java_home);
57
+ java = java_home + "/bin/java";
58
+ } else {
59
+ java = findOnPath("java");
60
+ }
61
+ }
62
+
63
+ if (java.empty()) {
64
+ printToConsole("No `java' executable found on PATH.");
65
+ return 255;
66
+ }
67
+
68
+ list<string> commandLine;
69
+ commandLine.push_back(java);
70
+ addOptionsToCommandLine(commandLine);
71
+
72
+ logMsg("Command line:");
73
+ for (list<string>::iterator it = commandLine.begin(); it != commandLine.end(); ++it) {
74
+ logMsg("\t%s", it->c_str());
75
+ }
76
+
77
+ char** newArgv = convertToArgvArray(commandLine);
78
+ int newArgc = commandLine.size();
79
+
80
+ if (printCommandLine) {
81
+ printListToConsole(commandLine);
82
+ for (int i = 0; i < newArgc; i++) {
83
+ free(newArgv[i]);
84
+ }
85
+ delete[] newArgv;
86
+ return 0;
87
+ }
88
+
89
+ if (!fileExists(java.c_str())) {
90
+ string msg = "No `java' exists at " + java + ", please double-check JAVA_HOME.\n";
91
+ printToConsole(msg.c_str());
92
+ return 255;
93
+ }
94
+
95
+ execv(java.c_str(), newArgv);
96
+
97
+ // shouldn't get here unless something bad happened with execv
98
+ logErr(true, true, "execv failed:");
99
+ return 255;
100
+ }