HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: //usr/local/rvm/src/ruby-2.3.8/template/ruby-runner.c.in
#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 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;
}