16 #include <sys/cygwin.h>
24 #include <sys/types.h>
28 #include <sys/pstat.h>
30 #if defined(LOAD_RELATIVE) && defined(HAVE_DLADDR)
37 #if defined(HAVE_FCNTL_H)
39 #elif defined(HAVE_SYS_FCNTL_H)
40 #include <sys/fcntl.h>
42 #ifdef HAVE_SYS_PARAM_H
43 # include <sys/param.h>
46 # define MAXPATHLEN 1024
55 #ifndef DISABLE_RUBYGEMS
56 # define DISABLE_RUBYGEMS 0
59 #define DEFAULT_RUBYGEMS_ENABLED "disabled"
61 #define DEFAULT_RUBYGEMS_ENABLED "enabled"
64 #define DISABLE_BIT(bit) (1U << disable_##bit)
71 #define DUMP_BIT(bit) (1U << dump_##bit)
110 #define src_encoding_index GET_VM()->src_encoding_index
128 #define forbid_setid(s) forbid_setid((s), opt)
143 unsigned short namelen, secondlen;
145 #define M(shortopt, longopt, desc) { \
146 shortopt " " longopt " " desc, \
147 (unsigned short)sizeof(shortopt), \
148 (unsigned short)sizeof(longopt), \
150 static const struct message usage_msg[] = {
151 M(
"-0[octal]",
"",
"specify record separator (\\0, if no argument)"),
152 M(
"-a",
"",
"autosplit mode with -n or -p (splits $_ into $F)"),
153 M(
"-c",
"",
"check syntax only"),
154 M(
"-Cdirectory",
"",
"cd to directory before executing your script"),
155 M(
"-d",
", --debug",
"set debugging flags (set $DEBUG to true)"),
156 M(
"-e 'command'",
"",
"one line of script. Several -e's allowed. Omit [programfile]"),
157 M(
"-Eex[:in]",
", --encoding=ex[:in]",
"specify the default external and internal character encodings"),
158 M(
"-Fpattern",
"",
"split() pattern for autosplit (-a)"),
159 M(
"-i[extension]",
"",
"edit ARGV files in place (make backup if extension supplied)"),
160 M(
"-Idirectory",
"",
"specify $LOAD_PATH directory (may be used more than once)"),
161 M(
"-l",
"",
"enable line ending processing"),
162 M(
"-n",
"",
"assume 'while gets(); ... end' loop around your script"),
163 M(
"-p",
"",
"assume loop like -n but print line also like sed"),
164 M(
"-rlibrary",
"",
"require the library before executing your script"),
165 M(
"-s",
"",
"enable some switch parsing for switches after script name"),
166 M(
"-S",
"",
"look for the script using PATH environment variable"),
167 M(
"-T[level=1]",
"",
"turn on tainting checks"),
168 M(
"-v",
", --verbose",
"print version number, then turn on verbose mode"),
169 M(
"-w",
"",
"turn warnings on for your script"),
170 M(
"-W[level=2]",
"",
"set warning level; 0=silence, 1=medium, 2=verbose"),
171 M(
"-x[directory]",
"",
"strip off text before #!ruby line and perhaps cd to directory"),
172 M(
"-h",
"",
"show this message, --help for more info"),
174 static const struct message help_msg[] = {
175 M(
"--copyright",
"",
"print the copyright"),
176 M(
"--enable=feature[,...]",
", --disable=feature[,...]",
177 "enable or disable features"),
178 M(
"--external-encoding=encoding",
", --internal-encoding=encoding",
179 "specify the default external or internal character encoding"),
180 M(
"--version",
"",
"print the version"),
181 M(
"--help",
"",
"show this message, -h for short message"),
183 static const struct message features[] = {
185 M(
"rubyopt",
"",
"RUBYOPT environment variable (default: enabled)"),
187 int i, w = 16, num =
numberof(usage_msg) - (help ? 1 : 0);
188 #define SHOW(m) do { \
189 int wrap = help && (m).namelen + (m).secondlen - 2 > w; \
190 printf(" %.*s%-*.*s%-*s%s\n", (m).namelen-1, (m).str, \
191 (wrap ? 0 : w - (m).namelen + 1), \
192 (help ? (m).secondlen-1 : 0), (m).str + (m).namelen, \
193 (wrap ? w + 3 : 0), (wrap ? "\n" : ""), \
194 (m).str + (m).namelen + (m).secondlen); \
197 printf(
"Usage: %s [switches] [--] [programfile] [arguments]\n", name);
198 for (i = 0; i < num; ++
i)
214 static char *newp, *oldp;
215 static int newl, oldl, notfound;
219 if (!newp && !notfound) {
220 newp =
getenv(
"RUBYLIB_PREFIX");
222 oldp = newp =
strdup(newp);
223 while (*newp && !
ISSPACE(*newp) && *newp !=
';') {
227 while (*newp && (
ISSPACE(*newp) || *newp ==
';')) {
231 if (newl == 0 || oldl == 0) {
232 rb_fatal(
"malformed RUBYLIB_PREFIX");
234 translit_char(newp,
'\\',
'/');
240 if (!newp || l < oldl ||
STRNCASECMP(oldp, s, oldl) != 0) {
246 memcpy(ptr + newl, s + oldl, l - oldl);
247 ptr[l + newl - oldl] = 0;
251 #define rubylib_mangled_path rb_str_new
266 for (s = p; *s && *s != sep; s =
CharNext(s));
274 push_include_cygwin(
const char *path,
VALUE (*filter)(
VALUE))
277 char rubylib[FILENAME_MAX];
286 for (s = p; *s && *s !=
';'; s =
CharNext(s));
298 #ifdef HAVE_CYGWIN_CONV_PATH
299 #define CONV_TO_POSIX_PATH(p, lib) \
300 cygwin_conv_path(CCP_WIN_A_TO_POSIX|CCP_RELATIVE, (p), (lib), sizeof(lib))
302 #define CONV_TO_POSIX_PATH(p, lib) \
303 cygwin_conv_to_posix_path((p), (lib))
305 if (CONV_TO_POSIX_PATH(p, rubylib) == 0)
313 #define push_include push_include_cygwin
348 if (*p ==
'.' && p[1] ==
'/')
359 #if defined _WIN32 || defined __CYGWIN__
360 static HMODULE libruby;
363 DllMain(HINSTANCE dll,
DWORD reason, LPVOID reserved)
365 if (reason == DLL_PROCESS_ATTACH)
371 rb_libruby_handle(
void)
389 ID id_initial_load_path_mark;
392 #if defined LOAD_RELATIVE
393 # if defined HAVE_DLADDR || defined HAVE_CYGWIN_CONV_PATH
394 # define VARIABLE_LIBPATH 1
396 # define VARIABLE_LIBPATH 0
398 # if VARIABLE_LIBPATH
407 #if defined _WIN32 || defined __CYGWIN__
408 # if VARIABLE_LIBPATH
411 GetModuleFileName(libruby, libpath,
MAXPATHLEN);
413 GetModuleFileName(libruby, libpath,
sizeof libpath);
415 #elif defined(__EMX__)
416 _execname(libpath,
sizeof(libpath) - 1);
417 #elif defined(HAVE_DLADDR)
432 #if !VARIABLE_LIBPATH
433 libpath[
sizeof(libpath) - 1] =
'\0';
436 translit_char(libpath,
'\\',
'/');
437 #elif defined __CYGWIN__
439 # if VARIABLE_LIBPATH
440 const int win_to_posix = CCP_WIN_A_TO_POSIX | CCP_RELATIVE;
441 size_t newsize = cygwin_conv_path(win_to_posix, libpath, 0, 0);
445 if (cygwin_conv_path(win_to_posix, libpath, p, newsize) == 0) {
452 char rubylib[FILENAME_MAX];
453 cygwin_conv_to_posix_path(libpath, rubylib);
454 strncpy(libpath, rubylib,
sizeof(libpath));
460 static const char bindir[] =
"/bin";
461 #ifdef LIBDIR_BASENAME
462 static const char libdir[] =
"/"LIBDIR_BASENAME;
464 static const char libdir[] =
"/lib";
466 const ptrdiff_t bindir_len = (ptrdiff_t)
sizeof(bindir) - 1;
467 const ptrdiff_t libdir_len = (ptrdiff_t)
sizeof(libdir) - 1;
469 #ifdef ENABLE_MULTIARCH
474 if (p - libpath >= bindir_len && !
STRNCASECMP(p - bindir_len, bindir, bindir_len)) {
477 else if (p - libpath >= libdir_len && !strncmp(p - libdir_len, libdir, libdir_len)) {
480 #ifdef ENABLE_MULTIARCH
487 if (p)
goto multiarch;
493 #if !VARIABLE_LIBPATH
495 strlcpy(libpath,
".",
sizeof(libpath));
498 baselen = p - libpath;
499 #define PREFIX_PATH() rb_str_new(libpath, baselen)
501 baselen = p - libpath;
504 #define PREFIX_PATH() sopath
507 #define BASEPATH() rb_str_buf_cat(rb_str_buf_new(baselen+len), libpath, baselen)
509 #define RUBY_RELATIVE(path, len) rb_str_buf_cat(BASEPATH(), (path), (len))
512 const size_t exec_prefix_len =
strlen(ruby_exec_prefix);
513 #define RUBY_RELATIVE(path, len) rubylib_mangled_path((path), (len))
514 #define PREFIX_PATH() RUBY_RELATIVE(ruby_exec_prefix, exec_prefix_len)
516 load_path =
GET_VM()->load_path;
518 if (safe_level == 0) {
527 size_t len =
strlen(paths);
529 rb_ivar_set(path, id_initial_load_path_mark, path);
607 if (s[1] ==
'-' && s[2] ==
'\0')
612 for (p = s + 1; *
p; p++) {
621 else if (*p !=
'_' && !
ISALNUM(*p)) {
624 rb_str_new2(
"invalid name for global variable - ");
625 if (!(p =
strchr(p,
'='))) {
631 name_error[1] = args[-1];
637 for (p = s + 1; *
p; ++
p) {
660 VALUE argstr, argary;
685 while ((i =
proc_options(argc, argv, opt, envopt)) > 1 && (argc -=
i) > 0) {
701 #define NAME_MATCH_P(name, str, len) \
702 ((len) < (int)sizeof(name) && strncmp((str), (name), (len)) == 0)
704 #define UNSET_WHEN(name, bit, str, len) \
705 if (NAME_MATCH_P((name), (str), (len))) { \
706 *(unsigned int *)arg &= ~(bit); \
710 #define SET_WHEN(name, bit, str, len) \
711 if (NAME_MATCH_P((name), (str), (len))) { \
712 *(unsigned int *)arg |= (bit); \
719 #define UNSET_WHEN_DISABLE(bit) UNSET_WHEN(#bit, DISABLE_BIT(bit), str, len)
723 *(
unsigned int *)arg = 0
U;
726 rb_warn(
"unknown argument for --enable: `%.*s'", len, str);
732 #define SET_WHEN_DISABLE(bit) SET_WHEN(#bit, DISABLE_BIT(bit), str, len)
736 *(
unsigned int *)arg = ~0
U;
739 rb_warn(
"unknown argument for --disable: `%.*s'", len, str);
745 #define SET_WHEN_DUMP(bit) SET_WHEN(#bit, DUMP_BIT(bit), str, len)
755 rb_warn(
"don't know how to dump `%.*s',", len, str);
756 rb_warn(
"but only [version, copyright, usage, yydebug, syntax, parsetree, parsetree_with_comment, insns].");
764 if (!elen) elen =
strlen(e);
770 "%s already set to %"PRIsVALUE, type, *name);
775 #define set_internal_encoding_once(opt, e, elen) \
776 set_option_encoding_once("default_internal", &(opt)->intern.enc.name, (e), (elen))
777 #define set_external_encoding_once(opt, e, elen) \
778 set_option_encoding_once("default_external", &(opt)->ext.enc.name, (e), (elen))
779 #define set_source_encoding_once(opt, e, elen) \
780 set_option_encoding_once("source", &(opt)->src.enc.name, (e), (elen))
785 long n, argc0 =
argc;
791 for (argc--, argv++; argc > 0; argc--, argv++) {
792 const char *
const arg = argv[0];
793 if (!arg || arg[0] !=
'-' || !arg[1])
800 if (envopt)
goto noenvopt;
806 if (envopt)
goto noenvopt;
810 if (envopt)
goto noenvopt;
822 if (envopt)
goto noenvopt;
865 if (envopt)
goto noenvopt;
871 if (envopt)
goto noenvopt;
878 if (envopt)
goto noenvopt;
883 if (envopt)
goto noenvopt;
890 if (envopt)
goto noenvopt;
897 if (envopt)
goto noenvopt;
927 if (envopt)
goto noenvopt;
933 if (envopt)
goto noenvopt;
936 if (*s && chdir(s) < 0) {
943 if (envopt)
goto noenvopt;
958 if (envopt)
goto noenvopt;
965 if (!*++s && (!--argc || !(s = *++argv))) {
983 enc_name =
"Windows-31J";
988 case 'N':
case 'n':
case 'A':
case 'a':
989 enc_name =
"ASCII-8BIT";
1027 if (envopt)
goto noenvopt;
1037 else if (v == 0 && numlen >= 2) {
1048 if (!s[1] || (s[1] ==
'\r' && !s[2])) {
1054 # define is_option_end(c, allow_hyphen) \
1055 (!(c) || ((allow_hyphen) && (c) == '-') || (c) == '=')
1056 # define check_envopt(name, allow_envopt) \
1057 (((allow_envopt) || !envopt) ? (void)0 : \
1058 rb_raise(rb_eRuntimeError, "invalid switch in RUBYOPT: --" name))
1059 # define need_argument(name, s, needs_arg) \
1060 ((*(s)++ ? !*(s) : (!--argc || !((s) = *++argv))) && (needs_arg) ? \
1061 rb_raise(rb_eRuntimeError, "missing argument for --" name) \
1063 # define is_option_with_arg(name, allow_hyphen, allow_envopt) \
1064 is_option_with_optarg(name, allow_hyphen, allow_envopt, Qtrue)
1065 # define is_option_with_optarg(name, allow_hyphen, allow_envopt, needs_arg) \
1066 (strncmp((name), s, n = sizeof(name) - 1) == 0 && is_option_end(s[n], (allow_hyphen)) ? \
1067 (check_envopt(name, (allow_envopt)), s += n, \
1068 need_argument(name, s, needs_arg), 1) : 0)
1070 if (strcmp(
"copyright", s) == 0) {
1071 if (envopt)
goto noenvopt_long;
1074 else if (strcmp(
"debug", s) == 0) {
1088 # define set_encoding_part(type) \
1089 if (!(p = strchr(s, ':'))) { \
1090 set_##type##_encoding_once(opt, s, 0); \
1094 set_##type##_encoding_once(opt, s, p-s); \
1097 if (!*(s = ++p))
break;
1099 if (!*(s = ++p))
break;
1100 #if defined ALLOW_DEFAULT_SOURCE_ENCODING && ALLOW_DEFAULT_SOURCE_ENCODING
1102 if (!*(s = ++p))
break;
1105 (arg[1] ==
'-' ?
"--encoding" :
"-E"), s);
1106 # undef set_encoding_part
1115 #if defined ALLOW_DEFAULT_SOURCE_ENCODING && ALLOW_DEFAULT_SOURCE_ENCODING
1120 else if (strcmp(
"version", s) == 0) {
1121 if (envopt)
goto noenvopt_long;
1124 else if (strcmp(
"verbose", s) == 0) {
1128 else if (strcmp(
"yydebug", s) == 0) {
1129 if (envopt)
goto noenvopt_long;
1135 else if (strcmp(
"help", s) == 0) {
1136 if (envopt)
goto noenvopt_long;
1142 "invalid option --%s (-h will show valid options)", s);
1154 "invalid option -%c (-h will show valid options)",
1155 (
int)(
unsigned char)*s);
1159 "invalid option -\\x%02X (-h will show valid options)",
1160 (
int)(
unsigned char)*s);
1176 # undef is_option_end
1177 # undef check_envopt
1178 # undef need_argument
1179 # undef is_option_with_arg
1180 # undef is_option_with_optarg
1185 return argc0 -
argc;
1210 #define rb_progname (GET_VM()->progname)
1211 #define rb_orig_progname (GET_VM()->orig_progname)
1226 #define rb_define_readonly_boolean(name, val) \
1227 rb_define_virtual_variable((name), (val) ? true_value : false_value, 0)
1350 opt->
src.
enc.name = src_enc_name;
1352 opt->
ext.
enc.name = ext_enc_name;
1358 rb_warning(
"-K is specified; it is for 1.8 compatibility and may cause odd behavior");
1385 char *path =
getenv(
"RUBYPATH");
1404 #if defined DOSISH || defined __CYGWIN__
1419 if (opt->
ext.
enc.name != 0) {
1425 if (opt->
src.
enc.name != 0) {
1429 if (opt->
ext.
enc.index >= 0) {
1461 #define PREPARE_PARSE_MAIN(expr) do { \
1462 rb_env_t *env = toplevel_context(toplevel_binding); \
1463 th->parse_in_eval--; \
1464 th->base_block = &env->block; \
1466 th->parse_in_eval++; \
1467 th->base_block = 0; \
1473 if (opt->
src.
enc.index >= 0) {
1500 if (opt->
ext.
enc.index >= 0) {
1517 if (!tree)
return Qfalse;
1528 printf(
"Syntax OK\n");
1601 if (strcmp(fname,
"-") == 0) {
1605 int fd,
mode = O_RDONLY;
1606 #if defined DOSISH || defined __CYGWIN__
1619 #if !defined DOSISH && !defined __CYGWIN__
1622 if (
fstat(fd, &st) != 0)
1633 CONST_ID(set_encoding,
"set_encoding");
1638 int no_src_enc = !opt->
src.
enc.name;
1639 int no_ext_enc = !opt->
ext.
enc.name;
1645 if (xflag || opt->
xflag) {
1673 goto search_shebang;
1681 if ((p =
strstr(p,
" -")) != 0) {
1688 else if (!
NIL_P(c)) {
1692 if (no_src_enc && opt->
src.
enc.name) {
1696 if (no_ext_enc && opt->
ext.
enc.name) {
1699 if (no_int_enc && opt->
intern.
enc.name) {
1703 else if (!
NIL_P(c)) {
1713 if (opt->
src.
enc.index >= 0) {
1716 else if (f == rb_stdin) {
1745 else if (f != rb_stdin) {
1869 if (uid != euid) opt->
setids |= 1;
1870 if (egid != gid) opt->
setids |= 2;
1871 if (uid && opt->
setids) {
1899 switch (*variable) {
1944 #if defined(USE_DLN_A_OUT)
1948 dln_argv0 = argv[0];
1951 for (i = 0; i <
argc; i++) {
1964 const char *
script_name = (argc > 0 && argv[0]) ? argv[0] :
"ruby";
1971 #ifndef HAVE_SETPROCTITLE
1973 extern void ruby_init_setproctitle(
int argc,
char *argv[]);
1974 ruby_init_setproctitle(argc, argv);
1978 return (
void*)(
struct RData*)iseq;
1984 int f0, f1, f2, fds[2];
1990 if (pipe(fds) == 0) {
1999 if (pipe(fds) == 0) {
2001 if (f1 && fds[1] != 1)
2003 if (f2 && fds[1] != 2)
2005 if (fds[1] != 1 && fds[1] != 2)
2026 #if defined(USE_DLN_A_OUT)
#define RB_TYPE_P(obj, type)
static void ruby_init_prelude(void)
static void process_sflag(int *sflag)
static VALUE load_file_internal(VALUE arg)
rb_funcall2(argv[0], id_yield, argc-1, argv+1)
static VALUE restore_lineno(VALUE lineno)
static void dump_option(const char *str, int len, void *arg)
size_t strlen(const char *)
VALUE rb_class_new_instance(int, VALUE *, VALUE)
#define scan_oct(s, l, e)
const char * rb_obj_classname(VALUE)
VALUE rb_str_tmp_new(long)
VALUE rb_gv_set(const char *, VALUE)
static VALUE proc_argv0(VALUE process)
RUBY_EXTERN VALUE rb_stdout
rb_funcall(memo->yielder, id_lshift, 1, rb_assoc_new(memo->prev_value, memo->prev_elts))
void ruby_each_words(const char *, void(*)(const char *, int, void *), void *)
VALUE rb_const_get(VALUE, ID)
void ruby_show_version(void)
Prints the version information of the CRuby interpreter to stdout.
void rb_define_global_const(const char *, VALUE)
VALUE rb_external_str_new_cstr(const char *)
VALUE rb_gv_get(const char *)
VALUE rb_ary_shift(VALUE ary)
VALUE rb_parser_end_seen_p(VALUE vparser)
VALUE rb_str_new_cstr(const char *)
VALUE rb_enc_from_encoding(rb_encoding *encoding)
static VALUE rb_f_chop(void)
VALUE rb_obj_freeze(VALUE)
void rb_define_hooked_variable(const char *, VALUE *, VALUE(*)(ANYARGS), void(*)(ANYARGS))
void rb_update_max_fd(int fd)
void ruby_show_copyright(void)
Prints the copyright notice of the CRuby interpreter to stdout and exits this process successfully...
rb_encoding * rb_default_internal_encoding(void)
VALUE rb_ary_push(VALUE ary, VALUE item)
void rb_lastline_set(VALUE)
static void add_modules(VALUE *req_list, const char *mod)
void rb_raise(VALUE exc, const char *fmt,...)
void ruby_init_loadpath_safe(int safe_level)
static VALUE expand_include_path(VALUE path)
void rb_enc_set_default_external(VALUE encoding)
VALUE rb_enc_associate(VALUE obj, rb_encoding *enc)
VALUE rb_ary_clear(VALUE ary)
VALUE rb_str_encode_ospath(VALUE)
static void require_libraries(VALUE *req_list)
VALUE rb_external_str_new(const char *, long)
#define M(shortopt, longopt, desc)
RUBY_EXTERN VALUE rb_output_rs
static void disable_option(const char *str, int len, void *arg)
const char ruby_exec_prefix[]
#define PREPARE_PARSE_MAIN(expr)
#define GetEnvPtr(obj, ptr)
static void verbose_setter(VALUE val, ID id, void *data)
static VALUE rb_f_sub(int argc, VALUE *argv)
void rb_define_global_function(const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a global function.
VALUE rb_funcall_passing_block(VALUE, ID, int, const VALUE *)
VALUE rb_lastline_get(void)
void * rb_load_file_str(VALUE)
void * rb_load_file(const char *)
RUBY_EXTERN VALUE rb_argv0
rb_encoding * rb_utf8_encoding(void)
void rb_load_fail(VALUE path, const char *err)
void rb_loaderror(const char *fmt,...)
VALUE rb_str_new_frozen(VALUE)
struct cmdline_options * opt
static void set_option_encoding_once(const char *type, VALUE *name, const char *e, long elen)
VALUE rb_parser_set_yydebug(VALUE self, VALUE flag)
VALUE rb_file_expand_path(VALUE, VALUE)
static rb_env_t * toplevel_context(VALUE toplevel_binding)
RUBY_EXTERN size_t strlcpy(char *, const char *, size_t)
void ruby_incpush(const char *)
#define MEMZERO(p, type, n)
void rb_exc_raise(VALUE mesg)
#define set_external_encoding_once(opt, e, elen)
static void fill_standard_fds(void)
static void enable_option(const char *str, int len, void *arg)
rb_encoding * rb_default_external_encoding(void)
static NODE * load_file(VALUE, VALUE, int, struct cmdline_options *)
NODE * rb_parser_compile_string(volatile VALUE vparser, const char *f, VALUE s, int line)
static void push_include(const char *path, VALUE(*filter)(VALUE))
VALUE rb_iseq_new_main(NODE *node, VALUE path, VALUE absolute_path)
#define is_option_with_arg(name, allow_hyphen, allow_envopt)
#define StringValuePtr(v)
#define STRCASECMP(s1, s2)
static void init_ids(struct cmdline_options *)
#define RUBY_RELATIVE(path, len)
struct cmdline_options::@173::@174 enc
VALUE rb_parser_encoding(VALUE vparser)
#define SET_WHEN_DUMP(bit)
void ruby_set_inplace_mode(const char *)
VALUE rb_reg_new(const char *, long, int)
#define GetBindingPtr(obj, ptr)
static VALUE false_value(void)
#define RARRAY_CONST_PTR(a)
#define RARRAY_AREF(a, i)
#define StringValueCStr(v)
static void moreswitches(const char *s, struct cmdline_options *opt, int envopt)
static void usage(const char *name, int help)
VALUE rb_str_cat2(VALUE, const char *)
void ruby_incpush_expand(const char *path)
#define UNSET_WHEN_DISABLE(bit)
#define DEFAULT_RUBYGEMS_ENABLED
static int rb_enc_dummy_p(rb_encoding *enc)
void rb_gvar_readonly_setter(VALUE val, ID id, void *data, struct rb_global_variable *gvar)
NODE * rb_parser_append_print(VALUE vparser, NODE *node)
VALUE rb_str_freeze(VALUE)
unsigned char buf[MIME_BUF_SIZE]
void ruby_push_include(const char *path, VALUE(*filter)(VALUE))
NODE * rb_parser_while_loop(VALUE vparser, NODE *node, int chop, int split)
struct cmdline_options::@173 src
void * ruby_process_options(int, char **)
void ruby_set_script_name(VALUE name)
Sets the current script name to this value.
VALUE rb_str_resize(VALUE, long)
void rb_define_module_function(VALUE module, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a module function for module.
void rb_w32_sysinit(int *argc, char ***argv)
void rb_fatal(const char *fmt,...)
void ruby_prog_init(void)
Defines built-in variables.
#define CONST_ID(var, str)
void rb_gc_register_mark_object(VALUE)
#define rubylib_mangled_path
VALUE rb_io_ungetbyte(VALUE, VALUE)
void rb_const_set(VALUE, ID, VALUE)
#define RBASIC_SET_CLASS_RAW(obj, cls)
RUBY_EXTERN VALUE rb_mProcess
#define set_encoding_part(type)
rb_encoding * rb_locale_encoding(void)
char * strchr(char *, char)
static int opt_enc_index(VALUE enc_name)
VALUE rb_io_getbyte(VALUE)
char * rb_enc_path_last_separator(const char *, const char *, rb_encoding *)
#define NAME_MATCH_P(name, str, len)
RUBY_EXTERN VALUE rb_stdin
VALUE rb_ensure(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*e_proc)(ANYARGS), VALUE data2)
static VALUE uscore_get(void)
RUBY_EXTERN VALUE rb_cString
static struct cmdline_options * cmdline_options_init(struct cmdline_options *opt)
struct cmdline_options::@173 intern
#define rb_intern_const(str)
RUBY_EXTERN void setproctitle(const char *fmt,...)
static VALUE proc_setproctitle(VALUE process, VALUE title)
static VALUE opt_W_getter(ID id, void *data)
RUBY_EXTERN char * strerror(int)
static VALUE identical_path(VALUE path)
VALUE rb_str_cat(VALUE, const char *, long)
VALUE rb_realpath_internal(VALUE basedir, VALUE path, int strict)
VALUE rb_parser_dump_tree(NODE *node, int comment)
#define set_source_encoding_once(opt, e, elen)
#define SET_WHEN_DISABLE(bit)
void ruby_script(const char *name)
Sets the current script name to this value.
void rb_set_safe_level(int)
const char ruby_initial_load_paths[]
static VALUE rb_f_gsub(int argc, VALUE *argv)
RUBY_EXTERN VALUE rb_cObject
void ruby_init_loadpath(void)
void rb_enc_set_default_internal(VALUE encoding)
void ruby_set_argv(int, char **)
VALUE rb_const_remove(VALUE, ID)
struct rb_encoding_entry * list
void rb_define_variable(const char *, VALUE *)
#define STRNCASECMP(s1, s2, n)
struct cmdline_options::@173 ext
#define set_internal_encoding_once(opt, e, elen)
RUBY_EXTERN char * strstr(const char *, const char *)
RUBY_EXTERN int dup2(int, int)
void ruby_gc_set_params(int safe_level)
#define RSTRING_LENINT(str)
#define src_encoding_index
rb_ivar_set(yielder, id_memo, LONG2NUM(++count))
void rb_vm_set_progname(VALUE filename)
VALUE rb_str_new(const char *, long)
VALUE rb_parser_new(void)
struct parser_params * parser
int rb_cloexec_open(const char *pathname, int flags, mode_t mode)
#define RBASIC_CLEAR_CLASS(obj)
NODE * rb_parser_compile_string_path(volatile VALUE vparser, VALUE f, VALUE s, int line)
rb_encoding * rb_ascii8bit_encoding(void)
void rb_warning(const char *fmt,...)
int rb_enc_find_index(const char *name)
void rb_stdio_set_default_encoding(void)
static void version(void)
static VALUE true_value(void)
#define RARRAY_ASET(a, i, v)
static VALUE rb_f_chomp(int argc, VALUE *argv)
VALUE rb_define_module(const char *name)
#define rb_define_readonly_boolean(name, val)
static VALUE locale_path(VALUE path)
static VALUE process_options(int argc, char **argv, struct cmdline_options *opt)
static rb_thread_t * GET_THREAD(void)
VALUE rb_iseq_disasm(VALUE self)
void rb_warn(const char *fmt,...)
NODE * rb_parser_compile_file_path(volatile VALUE vparser, VALUE fname, VALUE file, int start)
VALUE rb_io_fdopen(int, int, const char *)
char * strrchr(const char *, const char)
static struct @172 origarg
int parse_in_eval
Thread-local state of evaluation context.
VALUE rb_io_write(VALUE, VALUE)
rb_encoding * rb_enc_from_index(int index)
static long proc_options(long argc, char **argv, struct cmdline_options *opt, int envopt)
static void set_arg0(VALUE val, ID id)