mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
c09cdd9f5e
* template/ruby-runner.c.in (main): ignore empty or separator-only value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
33 lines
817 B
C
33 lines
817 B
C
#define _POSIX_C_SOURCE 200809L
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
|
|
#define BUILDDIR "@abs_top_builddir@"
|
|
#define LIBPATHENV "@LIBPATHENV@"
|
|
#define PATH_SEP '@PATH_SEPARATOR@'
|
|
#define RUBY_INSTALL_NAME "@RUBY_BASE_NAME@"
|
|
|
|
int
|
|
main(int argc, char **argv)
|
|
{
|
|
static const char builddir[] = BUILDDIR;
|
|
const char *libpath = getenv(LIBPATHENV);
|
|
if (libpath) {
|
|
while (*libpath == PATH_SEP) ++libpath;
|
|
}
|
|
if (libpath && *libpath) {
|
|
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"/"RUBY_INSTALL_NAME, argv);
|
|
return -1;
|
|
}
|