16 #include <sys/cygwin.h> 23 #include <sys/types.h> 27 #include <sys/pstat.h> 29 #if defined(LOAD_RELATIVE) && defined(HAVE_DLADDR) 36 #if defined(HAVE_FCNTL_H) 38 #elif defined(HAVE_SYS_FCNTL_H) 39 #include <sys/fcntl.h> 41 #ifdef HAVE_SYS_PARAM_H 42 # include <sys/param.h> 45 # define MAXPATHLEN 1024 48 # define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) 57 #ifndef DISABLE_RUBYGEMS 58 # define DISABLE_RUBYGEMS 0 61 #define DEFAULT_RUBYGEMS_ENABLED "disabled" 63 #define DEFAULT_RUBYGEMS_ENABLED "enabled" 67 #define FEATURE_BIT(bit) (1U << feature_##bit) 68 #define EACH_FEATURES(X, SEP) \ 75 X(frozen_string_literal) \ 77 #define EACH_DEBUG_FEATURES(X, SEP) \ 78 X(frozen_string_literal) \ 80 #define AMBIGUOUS_FEATURE_NAMES 0 81 #define DEFINE_FEATURE(bit) feature_##bit 82 #define DEFINE_DEBUG_FEATURE(bit) feature_debug_##bit 91 #define DEBUG_BIT(bit) (1U << feature_debug_##bit) 93 #define DUMP_BIT(bit) (1U << dump_##bit) 94 #define DEFINE_DUMP(bit) dump_##bit 95 #define EACH_DUMPS(X, SEP) \ 110 X(parsetree_with_comment) \ 149 #define src_encoding_index GET_VM()->src_encoding_index 180 #define forbid_setid(s) forbid_setid((s), opt) 188 show_usage_line(
const char *str,
unsigned int namelen,
unsigned int secondlen,
int help)
190 const unsigned int w = 16;
191 const int wrap = help && namelen + secondlen - 2 > w;
192 printf(
" %.*s%-*.*s%-*s%s\n", namelen-1, str,
193 (wrap ? 0 : w - namelen + 1),
194 (help ? secondlen-1 : 0), str + namelen,
195 (wrap ? w + 3 : 0), (wrap ?
"\n" :
""),
196 str + namelen + secondlen);
207 unsigned short namelen, secondlen;
209 #define M(shortopt, longopt, desc) { \ 210 shortopt " " longopt " " desc, \ 211 (unsigned short)sizeof(shortopt), \ 212 (unsigned short)sizeof(longopt), \ 214 static const struct message usage_msg[] = {
215 M(
"-0[octal]",
"",
"specify record separator (\\0, if no argument)"),
216 M(
"-a",
"",
"autosplit mode with -n or -p (splits $_ into $F)"),
217 M(
"-c",
"",
"check syntax only"),
218 M(
"-Cdirectory",
"",
"cd to directory before executing your script"),
219 M(
"-d",
", --debug",
"set debugging flags (set $DEBUG to true)"),
220 M(
"-e 'command'",
"",
"one line of script. Several -e's allowed. Omit [programfile]"),
221 M(
"-Eex[:in]",
", --encoding=ex[:in]",
"specify the default external and internal character encodings"),
222 M(
"-Fpattern",
"",
"split() pattern for autosplit (-a)"),
223 M(
"-i[extension]",
"",
"edit ARGV files in place (make backup if extension supplied)"),
224 M(
"-Idirectory",
"",
"specify $LOAD_PATH directory (may be used more than once)"),
225 M(
"-l",
"",
"enable line ending processing"),
226 M(
"-n",
"",
"assume 'while gets(); ... end' loop around your script"),
227 M(
"-p",
"",
"assume loop like -n but print line also like sed"),
228 M(
"-rlibrary",
"",
"require the library before executing your script"),
229 M(
"-s",
"",
"enable some switch parsing for switches after script name"),
230 M(
"-S",
"",
"look for the script using PATH environment variable"),
231 M(
"-T[level=1]",
"",
"turn on tainting checks"),
232 M(
"-v",
", --verbose",
"print version number, then turn on verbose mode"),
233 M(
"-w",
"",
"turn warnings on for your script"),
234 M(
"-W[level=2]",
"",
"set warning level; 0=silence, 1=medium, 2=verbose"),
235 M(
"-x[directory]",
"",
"strip off text before #!ruby line and perhaps cd to directory"),
236 M(
"-h",
"",
"show this message, --help for more info"),
238 static const struct message help_msg[] = {
239 M(
"--copyright",
"",
"print the copyright"),
240 M(
"--enable=feature[,...]",
", --disable=feature[,...]",
241 "enable or disable features"),
242 M(
"--external-encoding=encoding",
", --internal-encoding=encoding",
243 "specify the default external or internal character encoding"),
244 M(
"--version",
"",
"print the version"),
245 M(
"--help",
"",
"show this message, -h for short message"),
247 static const struct message features[] = {
250 M(
"rubyopt",
"",
"RUBYOPT environment variable (default: enabled)"),
251 M(
"frozen-string-literal",
"",
"freeze all string literals (default: disabled)"),
254 const int num =
numberof(usage_msg) - (help ? 1 : 0);
255 #define SHOW(m) show_usage_line((m).str, (m).namelen, (m).secondlen, help) 257 printf(
"Usage: %s [switches] [--] [programfile] [arguments]\n", name);
258 for (i = 0; i < num; ++i)
263 for (i = 0; i <
numberof(help_msg); ++i)
266 for (i = 0; i <
numberof(features); ++i)
270 #define rubylib_path_new rb_str_new 284 for (s = p; *s && *s != sep; s =
CharNext(s));
292 push_include_cygwin(
const char *path,
VALUE (*filter)(
VALUE))
295 char rubylib[FILENAME_MAX];
304 for (s = p; *s && *s !=
';'; s =
CharNext(s));
316 #ifdef HAVE_CYGWIN_CONV_PATH 317 #define CONV_TO_POSIX_PATH(p, lib) \ 318 cygwin_conv_path(CCP_WIN_A_TO_POSIX|CCP_RELATIVE, (p), (lib), sizeof(lib)) 320 # error no cygwin_conv_path 322 if (CONV_TO_POSIX_PATH(p, rubylib) == 0)
330 #define push_include push_include_cygwin 365 if (*p ==
'.' && p[1] ==
'/')
377 #if defined _WIN32 || defined __CYGWIN__ 378 static HMODULE libruby;
381 DllMain(HINSTANCE dll,
DWORD reason, LPVOID reserved)
383 if (reason == DLL_PROCESS_ATTACH)
389 rb_libruby_handle(
void)
395 translit_char_bin(
char *p,
int from,
int to)
398 if ((
unsigned char)*p == from)
413 # define IF_UTF8_PATH(t, f) t 415 # define IF_UTF8_PATH(t, f) f 436 #if defined(LOAD_RELATIVE) && defined(HAVE_DLADDR) 438 dladdr_path(
const void* addr)
443 if (!dladdr(addr, &dli)) {
447 else if (dli.dli_fname ==
origarg.argv[0]) {
461 #define INITIAL_LOAD_PATH_MARK rb_intern_const("@gem_prelude_index") 467 ID id_initial_load_path_mark;
469 #if defined LOAD_RELATIVE 470 # if defined HAVE_DLADDR || defined __CYGWIN__ || defined _WIN32 471 # define VARIABLE_LIBPATH 1 473 # define VARIABLE_LIBPATH 0 475 # if VARIABLE_LIBPATH 484 #if defined _WIN32 || defined __CYGWIN__ 490 ret = GetModuleFileNameW(libruby, wlibpath, len),
496 if (!ret || ret > len)
rb_fatal(
"failed to get module file name");
497 for (len = ret, i = 0; i <
len; ++i) {
498 if (wlibpath[i] ==
L'\\') {
503 len = WideCharToMultiByte(CP_UTF8, 0, wlibpath, ret,
NULL, 0,
NULL,
NULL);
506 WideCharToMultiByte(CP_UTF8, 0, wlibpath, ret, libpath, len,
NULL,
NULL);
509 #elif defined(HAVE_DLADDR) 514 #if !VARIABLE_LIBPATH 515 libpath[
sizeof(libpath) - 1] =
'\0';
517 #if defined DOSISH && !defined _WIN32 518 translit_char(libpath,
'\\',
'/');
519 #elif defined __CYGWIN__ 521 const int win_to_posix = CCP_WIN_A_TO_POSIX | CCP_RELATIVE;
522 size_t newsize = cygwin_conv_path(win_to_posix, libpath, 0, 0);
526 if (cygwin_conv_path(win_to_posix, libpath, p, newsize) == 0) {
536 static const char bindir[] =
"/bin";
537 #ifdef LIBDIR_BASENAME 538 static const char libdir[] =
"/"LIBDIR_BASENAME;
540 static const char libdir[] =
"/lib";
542 const ptrdiff_t bindir_len = (ptrdiff_t)
sizeof(bindir) - 1;
543 const ptrdiff_t libdir_len = (ptrdiff_t)
sizeof(libdir) - 1;
545 #ifdef ENABLE_MULTIARCH 550 if (p - libpath >= bindir_len && !
STRNCASECMP(p - bindir_len, bindir, bindir_len)) {
553 else if (p - libpath >= libdir_len && !strncmp(p - libdir_len, libdir, libdir_len)) {
556 #ifdef ENABLE_MULTIARCH 563 if (p)
goto multiarch;
567 #if !VARIABLE_LIBPATH 571 #if !VARIABLE_LIBPATH 573 strlcpy(libpath,
".",
sizeof(libpath));
576 baselen = p - libpath;
577 #define PREFIX_PATH() rb_str_new(libpath, baselen) 579 baselen = p - libpath;
582 #define PREFIX_PATH() sopath 585 #define BASEPATH() rb_str_buf_cat(rb_str_buf_new(baselen+len), libpath, baselen) 587 #define RUBY_RELATIVE(path, len) rb_str_buf_cat(BASEPATH(), (path), (len)) 590 #define RUBY_RELATIVE(path, len) rubylib_path_new((path), (len)) 591 #define PREFIX_PATH() RUBY_RELATIVE(ruby_exec_prefix, exec_prefix_len) 593 load_path =
GET_VM()->load_path;
595 if (safe_level == 0) {
603 rb_ivar_set(path, id_initial_load_path_mark, path);
671 if (s[1] ==
'-' && s[2] ==
'\0')
676 for (p = s + 1; *p; p++) {
685 else if (*p !=
'_' && !
ISALNUM(*p)) {
688 rb_str_new2(
"invalid name for global variable - ");
689 if (!(p =
strchr(p,
'='))) {
695 name_error[1] = args[-1];
701 for (p = s + 1; *p; ++p) {
724 VALUE argstr, argary;
739 while (*p && !
ISSPACE(*p)) ++p;
749 while ((i =
proc_options(argc, argv, opt, envopt)) > 1 && (argc -= i) > 0) {
768 if (len == 0)
return 0;
770 while (
TOLOWER(*str) == *name) {
771 if (!--len || !*++str)
return 1;
774 if (*str !=
'-' && *str !=
'_')
return 0;
776 if (*name !=
'-' && *name !=
'_')
return 0;
783 #define NAME_MATCH_P(name, str, len) \ 784 ((len) < (int)sizeof(name) && name_match_p((name), (str), (len))) 786 #define UNSET_WHEN(name, bit, str, len) \ 787 if (NAME_MATCH_P((name), (str), (len))) { \ 788 *(unsigned int *)arg &= ~(bit); \ 792 #define SET_WHEN(name, bit, str, len) \ 793 if (NAME_MATCH_P((name), (str), (len))) { \ 794 *(unsigned int *)arg |= (bit); \ 798 #define LITERAL_NAME_ELEMENT(name) #name 804 unsigned int *argp = arg;
805 unsigned int mask = ~0
U;
806 #if AMBIGUOUS_FEATURE_NAMES 807 unsigned int set = 0
U;
809 #define SET_FEATURE(bit) \ 810 if (NAME_MATCH_P(#bit, str, len)) {set |= mask = FEATURE_BIT(bit); ++matched;} 812 #define SET_FEATURE(bit) \ 813 if (NAME_MATCH_P(#bit, str, len)) {mask = FEATURE_BIT(bit); goto found;} 818 *argp = (*argp & ~mask) | (mask & enable);
821 #if AMBIGUOUS_FEATURE_NAMES 822 if (matched == 1)
goto found;
825 #define ADD_FEATURE_NAME(bit) \ 826 if (FEATURE_BIT(bit) & set) { \ 827 rb_str_cat_cstr(mesg, #bit); \ 828 if (--matched) rb_str_cat_cstr(mesg, ", "); \ 833 #undef ADD_FEATURE_NAME 836 rb_warn(
"unknown argument for --%s: `%.*s'",
837 enable ?
"enable" :
"disable", len, str);
857 #define SET_WHEN_DEBUG(bit) SET_WHEN(#bit, DEBUG_BIT(bit), str, len) 859 rb_warn(
"unknown argument for --debug: `%.*s'", len, str);
860 rb_warn(
"debug features are [%.*s].", (
int)
strlen(list), list);
867 #define SET_WHEN_DUMP(bit) SET_WHEN(#bit, DUMP_BIT(bit), str, len) 869 rb_warn(
"don't know how to dump `%.*s',", len, str);
878 if (!elen) elen =
strlen(e);
884 "%s already set to %"PRIsVALUE, type, *name);
889 #define set_internal_encoding_once(opt, e, elen) \ 890 set_option_encoding_once("default_internal", &(opt)->intern.enc.name, (e), (elen)) 891 #define set_external_encoding_once(opt, e, elen) \ 892 set_option_encoding_once("default_external", &(opt)->ext.enc.name, (e), (elen)) 893 #define set_source_encoding_once(opt, e, elen) \ 894 set_option_encoding_once("source", &(opt)->src.enc.name, (e), (elen)) 899 long n, argc0 =
argc;
906 for (argc--, argv++; argc > 0; argc--, argv++) {
907 const char *
const arg = argv[0];
908 if (!arg || arg[0] !=
'-' || !arg[1])
915 if (envopt)
goto noenvopt;
921 if (envopt)
goto noenvopt;
925 if (envopt)
goto noenvopt;
937 if (envopt)
goto noenvopt;
986 if (envopt)
goto noenvopt;
992 if (envopt)
goto noenvopt;
999 if (envopt)
goto noenvopt;
1004 if (envopt)
goto noenvopt;
1011 if (envopt)
goto noenvopt;
1018 if (envopt)
goto noenvopt;
1039 else if (argc > 1) {
1046 if (envopt)
goto noenvopt;
1052 if (envopt)
goto noenvopt;
1055 if (*s && chdir(s) < 0) {
1062 if (envopt)
goto noenvopt;
1063 if (!*++s && (!--argc || !(s = *++argv) || !*s)) {
1072 if (envopt)
goto noenvopt;
1079 if (!*++s && (!--argc || !(s = *++argv))) {
1094 enc_name =
"EUC-JP";
1097 enc_name =
"Windows-31J";
1102 case 'N':
case 'n':
case 'A':
case 'a':
1103 enc_name =
"ASCII-8BIT";
1134 else if (argc > 1) {
1141 if (envopt)
goto noenvopt;
1151 else if (v == 0 && numlen >= 2) {
1162 if (!s[1] || (s[1] ==
'\r' && !s[2])) {
1168 # define is_option_end(c, allow_hyphen) \ 1169 (!(c) || ((allow_hyphen) && (c) == '-') || (c) == '=') 1170 # define check_envopt(name, allow_envopt) \ 1171 (((allow_envopt) || !envopt) ? (void)0 : \ 1172 rb_raise(rb_eRuntimeError, "invalid switch in RUBYOPT: --" name)) 1173 # define need_argument(name, s, needs_arg, next_arg) \ 1174 ((*(s) ? !*++(s) : (next_arg) && (!argc || !((s) = argv[1]) || (--argc, ++argv, 0))) && (needs_arg) ? \ 1175 rb_raise(rb_eRuntimeError, "missing argument for --" name) \ 1177 # define is_option_with_arg(name, allow_hyphen, allow_envopt) \ 1178 is_option_with_optarg(name, allow_hyphen, allow_envopt, Qtrue, Qtrue) 1179 # define is_option_with_optarg(name, allow_hyphen, allow_envopt, needs_arg, next_arg) \ 1180 (strncmp((name), s, n = sizeof(name) - 1) == 0 && is_option_end(s[n], (allow_hyphen)) ? \ 1181 (check_envopt(name, (allow_envopt)), s += n, \ 1182 need_argument(name, s, needs_arg, next_arg), 1) : 0) 1184 if (strcmp(
"copyright", s) == 0) {
1185 if (envopt)
goto noenvopt_long;
1207 # define set_encoding_part(type) \ 1208 if (!(p = strchr(s, ':'))) { \ 1209 set_##type##_encoding_once(opt, s, 0); \ 1213 set_##type##_encoding_once(opt, s, p-s); \ 1216 if (!*(s = ++p))
break;
1218 if (!*(s = ++p))
break;
1219 #if defined ALLOW_DEFAULT_SOURCE_ENCODING && ALLOW_DEFAULT_SOURCE_ENCODING 1221 if (!*(s = ++p))
break;
1224 (arg[1] ==
'-' ?
"--encoding" :
"-E"), s);
1225 # undef set_encoding_part 1234 #if defined ALLOW_DEFAULT_SOURCE_ENCODING && ALLOW_DEFAULT_SOURCE_ENCODING 1239 else if (strcmp(
"version", s) == 0) {
1240 if (envopt)
goto noenvopt_long;
1243 else if (strcmp(
"verbose", s) == 0) {
1247 else if (strcmp(
"yydebug", s) == 0) {
1248 if (envopt)
goto noenvopt_long;
1254 else if (strcmp(
"help", s) == 0) {
1255 if (envopt)
goto noenvopt_long;
1261 "invalid option --%s (-h will show valid options)", s);
1273 "invalid option -%c (-h will show valid options)",
1274 (
int)(
unsigned char)*s);
1278 "invalid option -\\x%02X (-h will show valid options)",
1279 (
int)(
unsigned char)*s);
1295 # undef is_option_end 1296 # undef check_envopt 1297 # undef need_argument 1298 # undef is_option_with_arg 1299 # undef is_option_with_optarg 1305 return argc0 -
argc;
1330 #define rb_progname (GET_VM()->progname) 1331 #define rb_orig_progname (GET_VM()->orig_progname) 1346 #define rb_define_readonly_boolean(name, val) \ 1347 rb_define_virtual_variable((name), (val) ? true_value : false_value, 0) 1471 opt->
src.
enc.name = src_enc_name;
1473 opt->
ext.
enc.name = ext_enc_name;
1479 rb_warning(
"-K is specified; it is for 1.8 compatibility and may cause odd behavior");
1502 char *path =
getenv(
"RUBYPATH");
1524 #elif defined DOSISH 1538 if (opt->
ext.
enc.name != 0) {
1544 if (opt->
src.
enc.name != 0) {
1548 if (opt->
ext.
enc.index >= 0) {
1569 for (i = 0; i <
RARRAY_LEN(load_path); ++i) {
1574 if (newpath == path)
continue;
1579 if (mark)
rb_ivar_set(path, id_initial_load_path_mark, path);
1593 #define SET_COMPILE_OPTION(h, o, name) \ 1594 rb_hash_aset((h), ID2SYM(rb_intern_const(#name)), \ 1595 ((o)->features & FEATURE_BIT(name) ? Qtrue : Qfalse)); 1599 #undef SET_COMPILE_OPTION 1618 if (opt->
src.
enc.index >= 0) {
1624 if (ienc) eenc = ienc;
1655 if (!dump)
return Qtrue;
1658 if (opt->
ext.
enc.index >= 0) {
1675 if (!tree)
return Qfalse;
1681 printf(
"Syntax OK\n");
1683 if (!dump)
return Qtrue;
1701 if (!dump)
return Qtrue;
1717 if (!dump)
return Qtrue;
1734 if (str[len-1] ==
'\n' && str[len-2] ==
'\r') {
1735 rb_warn(
"shebang line ends with \\r may cause a problem");
1739 #define warn_cr_in_shebang(str, len) (void)0 1767 CONST_ID(set_encoding,
"set_encoding");
1773 int no_src_enc = !opt->
src.
enc.name;
1774 int no_ext_enc = !opt->
ext.
enc.name;
1780 if (xflag || opt->
xflag) {
1788 if (len > 2 && str[0] ==
'#' && str[1] ==
'!') {
1810 goto search_shebang;
1815 if (*str ==
'\n') *str-- =
'\0';
1816 if (*str ==
'\r') *str-- =
'\0';
1818 if ((p =
strstr(p,
" -")) != 0) {
1826 else if (!
NIL_P(c)) {
1830 if (no_src_enc && opt->
src.
enc.name) {
1834 if (no_ext_enc && opt->
ext.
enc.name) {
1837 if (no_int_enc && opt->
intern.
enc.name) {
1841 else if (!
NIL_P(c)) {
1853 if (opt->
src.
enc.index >= 0) {
1882 if (flen == 1 && fname[0] ==
'-') {
1889 #if defined O_NONBLOCK && HAVE_FCNTL && !(O_NONBLOCK & O_ACCMODE) 1891 # define MODE_TO_LOAD (O_RDONLY | O_NONBLOCK) 1892 #elif defined O_NDELAY && HAVE_FCNTL && !(O_NDELAY & O_ACCMODE) 1893 # define MODE_TO_LOAD (O_RDONLY | O_NDELAY) 1895 # define MODE_TO_LOAD (O_RDONLY) 1898 #if defined DOSISH || defined __CYGWIN__ 1899 # define isdirsep(x) ((x) == '/' || (x) == '\\') 1901 static const char exeext[] =
".exe";
1902 enum {extlen =
sizeof(exeext)-1};
1903 if (flen > extlen && !
isdirsep(fname[flen-extlen-1]) &&
1904 STRNCASECMP(fname+flen-extlen, exeext, extlen) == 0) {
1922 #if defined HAVE_FCNTL && MODE_TO_LOAD != O_RDONLY 2111 if (uid != euid) opt->
setids |= 1;
2112 if (egid != gid) opt->
setids |= 2;
2113 if (uid && opt->
setids) {
2133 VALUE *variable = data;
2140 VALUE *variable = data;
2141 switch (*variable) {
2185 #if defined(USE_DLN_A_OUT) 2189 dln_argv0 = argv[0];
2192 for (i = 0; i <
argc; i++) {
2212 #ifndef HAVE_SETPROCTITLE 2216 return (
void*)(
struct RData*)iseq;
2222 int f0, f1, f2, fds[2];
2228 if (pipe(fds) == 0) {
2237 if (pipe(fds) == 0) {
2239 if (f1 && fds[1] != 1)
2241 if (f2 && fds[1] != 2)
2243 if (fds[1] != 1 && fds[1] != 2)
2263 #if defined(USE_DLN_A_OUT) #define STRNCASECMP(s1, s2, n)
RUBY_EXTERN VALUE rb_cString
void rb_define_global_const(const char *, VALUE)
#define RBASIC_CLEAR_CLASS(obj)
struct ruby_cmdline_options::@171::@172 enc
static void ruby_init_prelude(void)
static void process_sflag(int *sflag)
RUBY_EXTERN VALUE rb_mProcess
VALUE rb_parser_dump_tree(NODE *node, int comment)
static void show_usage_line(const char *str, unsigned int namelen, unsigned int secondlen, int help)
NODE * rb_parser_compile_string_path(VALUE vparser, VALUE f, VALUE s, int line)
static void dump_option(const char *str, int len, void *arg)
size_t strlen(const char *)
void rb_update_max_fd(int fd)
static void moreswitches(const char *s, ruby_cmdline_options_t *opt, int envopt)
#define scan_oct(s, l, e)
const char ruby_exec_prefix[]
void * rb_parser_load_file(VALUE parser, VALUE fname_v)
static VALUE proc_argv0(VALUE process)
void ruby_set_inplace_mode(const char *)
int rb_cloexec_open(const char *pathname, int flags, mode_t mode)
VALUE rb_str_cat(VALUE, const char *, long)
#define INITIAL_LOAD_PATH_MARK
void ruby_each_words(const char *, void(*)(const char *, int, void *), void *)
void ruby_show_version(void)
Prints the version information of the CRuby interpreter to stdout.
NODE * rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE file, int start)
VALUE rb_ary_shift(VALUE ary)
static const struct rb_block * toplevel_context(rb_binding_t *bind)
VALUE rb_parser_end_seen_p(VALUE vparser)
#define SET_WHEN_DEBUG(bit)
VALUE rb_exc_new_str(VALUE etype, VALUE str)
int rb_enc_dummy_p(rb_encoding *enc)
VALUE rb_enc_from_encoding(rb_encoding *encoding)
#define DEFINE_DEBUG_FEATURE(bit)
static VALUE rb_f_chop(void)
RUBY_EXTERN VALUE rb_stdin
rb_encoding * rb_default_internal_encoding(void)
VALUE rb_ary_push(VALUE ary, VALUE item)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
void rb_str_set_len(VALUE, long)
static void add_modules(VALUE *req_list, const char *mod)
int rb_gc_for_fd(int err)
void rb_raise(VALUE exc, const char *fmt,...)
void ruby_init_loadpath_safe(int safe_level)
static long proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt)
static VALUE expand_include_path(VALUE path)
#define RSTRING_GETMEM(str, ptrvar, lenvar)
void rb_enc_set_default_external(VALUE encoding)
VALUE rb_enc_associate(VALUE obj, rb_encoding *enc)
VALUE rb_io_getbyte(VALUE)
VALUE rb_ary_clear(VALUE ary)
static void require_libraries(VALUE *req_list)
VALUE rb_readlink(VALUE path, rb_encoding *resultenc)
#define M(shortopt, longopt, desc)
static struct @170 origarg
static void disable_option(const char *str, int len, void *arg)
static int name_match_p(const char *name, const char *str, size_t len)
static void verbose_setter(VALUE val, ID id, void *data)
VALUE rb_io_write(VALUE, VALUE)
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_utf8_str_new_cstr(const char *)
rb_encoding * rb_utf8_encoding(void)
void rb_load_fail(VALUE path, const char *err)
VALUE rb_str_tmp_new(long)
void rb_loaderror(const char *fmt,...)
VALUE rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ecflags, VALUE ecopts)
static void set_option_encoding_once(const char *type, VALUE *name, const char *e, long elen)
VALUE rb_external_str_new_cstr(const char *)
VALUE rb_parser_set_yydebug(VALUE self, VALUE flag)
const char * rb_obj_classname(VALUE)
VALUE rb_gv_set(const char *, VALUE)
void ruby_incpush(const char *path)
VALUE rb_utf8_str_new(const char *, long)
static NODE * load_file(VALUE, VALUE, int, ruby_cmdline_options_t *)
void rb_exc_raise(VALUE mesg)
#define RBASIC_SET_CLASS_RAW(obj, cls)
#define RB_TYPE_P(obj, type)
#define set_external_encoding_once(opt, e, elen)
static void fill_standard_fds(void)
struct ruby_cmdline_options::@171 src
#define MEMZERO(p, type, n)
static void debug_option(const char *str, int len, void *arg)
void rb_set_safe_level(int)
static void enable_option(const char *str, int len, void *arg)
VALUE rb_lastline_get(void)
rb_encoding * rb_default_external_encoding(void)
RUBY_EXTERN VALUE rb_output_rs
static void push_include(const char *path, VALUE(*filter)(VALUE))
static VALUE open_load_file(VALUE fname_v, int *xflag)
VALUE rb_str_encode_ospath(VALUE path)
#define is_option_with_arg(name, allow_hyphen, allow_envopt)
#define RUBY_RELATIVE(path, len)
RUBY_EXTERN VALUE rb_cObject
VALUE rb_parser_encoding(VALUE vparser)
#define SET_WHEN_DUMP(bit)
RUBY_EXTERN char * strstr(const char *, const char *)
#define DEFINE_FEATURE(bit)
#define GetBindingPtr(obj, ptr)
static VALUE false_value(void)
VALUE rb_str_cat2(VALUE, const char *)
#define ECONV_INVALID_REPLACE
static void usage(const char *name, int help)
static VALUE enc_name(VALUE self)
void ruby_incpush_expand(const char *path)
#define DEFAULT_RUBYGEMS_ENABLED
void rb_lastline_set(VALUE)
#define IF_UTF8_PATH(t, f)
NODE * rb_parser_append_print(VALUE vparser, NODE *node)
VALUE rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to)
static void init_ids(ruby_cmdline_options_t *)
VALUE rb_parser_set_context(VALUE vparser, const struct rb_block *base, int main)
void rb_gc_register_mark_object(VALUE obj)
void ruby_push_include(const char *path, VALUE(*filter)(VALUE))
ruby_cmdline_options_t * opt
VALUE rb_class_new_instance(int, const VALUE *, VALUE)
NODE * rb_parser_while_loop(VALUE vparser, NODE *node, int chop, int split)
rb_iseq_t * rb_iseq_new_main(NODE *node, VALUE path, VALUE absolute_path, const rb_iseq_t *parent)
#define LITERAL_NAME_ELEMENT(name)
VALUE rb_str_resize(VALUE, long)
void ruby_set_script_name(VALUE name)
Sets the current script name to this value.
VALUE rb_const_get(VALUE, ID)
void rb_define_module_function(VALUE module, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a module function for module.
VALUE rb_io_fdopen(int, int, const char *)
#define RARRAY_CONST_PTR(a)
VALUE rb_reg_new(const char *, long, int)
VALUE rb_sprintf(const char *format,...)
int ruby_is_fd_loadable(int fd)
void rb_gvar_readonly_setter(VALUE v, ID id, void *d, struct rb_global_variable *g)
void rb_fatal(const char *fmt,...)
void ruby_prog_init(void)
Defines built-in variables.
#define EACH_DEBUG_FEATURES(X, SEP)
static const rb_iseq_t * vm_block_iseq(const struct rb_block *block)
void rb_str_modify_expand(VALUE, long)
VALUE rb_ivar_set(VALUE, ID, VALUE)
unsigned char buf[MIME_BUF_SIZE]
void rb_thread_wait_fd(int)
void rb_const_set(VALUE, ID, VALUE)
static VALUE restore_load_file(VALUE arg)
VALUE rb_vm_top_self(void)
#define set_encoding_part(type)
rb_encoding * rb_locale_encoding(void)
static VALUE process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
#define EACH_DUMPS(X, SEP)
char * strchr(char *, char)
const char ruby_initial_load_paths[]
struct ruby_cmdline_options::@171 intern
static int opt_enc_index(VALUE enc_name)
#define NAME_MATCH_P(name, str, len)
RUBY_EXTERN size_t strlcpy(char *, const char *, size_t)
VALUE rb_ensure(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*e_proc)(ANYARGS), VALUE data2)
VALUE rb_str_new_cstr(const char *)
static VALUE uscore_get(void)
VALUE rb_io_ungetbyte(VALUE, VALUE)
void ruby_gc_set_params(int safe_level)
void rb_define_hooked_variable(const char *, VALUE *, VALUE(*)(ANYARGS), void(*)(ANYARGS))
register unsigned int len
static VALUE proc_setproctitle(VALUE process, VALUE title)
static VALUE opt_W_getter(ID id, void *data)
#define StringValueCStr(v)
static VALUE external_str_new_cstr(const char *p)
static VALUE identical_path(VALUE path)
#define ECONV_UNDEF_REPLACE
static void warn_cr_in_shebang(const char *str, long len)
#define RARRAY_ASET(a, i, v)
VALUE rb_iseq_disasm(const rb_iseq_t *iseq)
#define set_source_encoding_once(opt, e, elen)
VALUE rb_funcall_passing_block(VALUE, ID, int, const VALUE *)
#define SET_COMPILE_OPTION(h, o, name)
#define RARRAY_AREF(a, i)
void * ruby_process_options(int argc, char **argv)
void ruby_script(const char *name)
Sets the current script name to this value.
VALUE rb_file_expand_path(VALUE fname, VALUE dname)
static VALUE rb_f_gsub(int argc, VALUE *argv)
void ruby_init_loadpath(void)
void rb_enc_set_default_internal(VALUE encoding)
RUBY_EXTERN char * strerror(int)
void ruby_set_argv(int argc, char **argv)
struct rb_encoding_entry * list
void rb_define_variable(const char *, VALUE *)
VALUE rb_str_cat_cstr(VALUE, const char *)
#define set_internal_encoding_once(opt, e, elen)
static VALUE mark(VALUE self)
#define src_encoding_index
static ruby_cmdline_options_t * cmdline_options_init(ruby_cmdline_options_t *opt)
void rb_vm_set_progname(VALUE filename)
VALUE rb_parser_new(void)
VALUE rb_realpath_internal(VALUE basedir, VALUE path, int strict)
char * rb_enc_path_last_separator(const char *path, const char *end, rb_encoding *enc)
#define StringValuePtr(v)
void ruby_sysinit(int *argc, char ***argv)
Initializes the process for ruby(1).
void * rb_load_file_str(VALUE fname_v)
RUBY_EXTERN int dup2(int, int)
VALUE rb_str_new_frozen(VALUE)
#define EACH_FEATURES(X, SEP)
static VALUE load_file_internal(VALUE argp_v)
#define ruby_show_copyright()
rb_encoding * rb_ascii8bit_encoding(void)
void rb_warning(const char *fmt,...)
int rb_enc_find_index(const char *name)
static void feature_option(const char *str, int len, void *arg, const unsigned int enable)
#define is_option_with_optarg(name, allow_hyphen, allow_envopt, needs_arg, next_arg)
#define RSTRING_LENINT(str)
#define CONST_ID(var, str)
RUBY_EXTERN VALUE rb_stdout
#define rb_intern_const(str)
VALUE rb_obj_freeze(VALUE)
static VALUE true_value(void)
static VALUE rb_f_chomp(int argc, VALUE *argv)
VALUE rb_define_module(const char *name)
void rb_stdio_set_default_encoding(void)
void ruby_init_setproctitle(int argc, char *argv[])
VALUE rb_const_remove(VALUE, ID)
#define rb_define_readonly_boolean(name, val)
static VALUE locale_path(VALUE path)
RUBY_EXTERN void setproctitle(const char *fmt,...)
void rb_warn(const char *fmt,...)
struct ruby_cmdline_options::@171 ext
NODE * rb_parser_compile_string(VALUE vparser, const char *f, VALUE s, int line)
void rb_w32_sysinit(int *, char ***)
VALUE rb_attr_get(VALUE, ID)
char * strrchr(const char *, const char)
rb_encoding * rb_enc_from_index(int index)
void * rb_load_file(const char *fname)
VALUE rb_str_new(const char *, long)
static void set_arg0(VALUE val, ID id)