mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
ruby-runner.h
* template/ruby-runner.h.in: separate configured part from ruby-runner.c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1a88b871d1
commit
7343b492a2
4 changed files with 8 additions and 7 deletions
35
ruby-runner.c
Normal file
35
ruby-runner.c
Normal file
|
@ -0,0 +1,35 @@
|
|||
#define _POSIX_C_SOURCE 200809L
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "ruby-runner.h"
|
||||
|
||||
#define STRINGIZE(expr) STRINGIZE0(expr)
|
||||
#define STRINGIZE0(expr) #expr
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
static const char builddir[] = BUILDDIR;
|
||||
const char *libpath = getenv(LIBPATHENV);
|
||||
char c = 0;
|
||||
|
||||
if (libpath) {
|
||||
while ((c = *libpath) == PATH_SEP) ++libpath;
|
||||
}
|
||||
if (c) {
|
||||
size_t n = strlen(libpath);
|
||||
char *e = malloc(sizeof(builddir)+n+1);
|
||||
memcpy(e, builddir, sizeof(builddir)-1);
|
||||
e[sizeof(builddir)-1] = PATH_SEP;
|
||||
memcpy(e+sizeof(builddir), libpath, n+1);
|
||||
libpath = e;
|
||||
}
|
||||
else {
|
||||
libpath = builddir;
|
||||
}
|
||||
setenv(LIBPATHENV, libpath, 1);
|
||||
execv(BUILDDIR"/"STRINGIZE(RUBY_INSTALL_NAME), argv);
|
||||
return -1;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue