Ruby  2.4.2p198(2017-09-14revision59899)
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
ruby.c File Reference
#include "internal.h"
#include "ruby/thread.h"
#include "eval_intern.h"
#include "dln.h"
#include <stdio.h>
#include <sys/types.h>
#include <ctype.h>
#include "ruby/util.h"
Include dependency graph for ruby.c:

Go to the source code of this file.

Data Structures

struct  ruby_cmdline_options
 
struct  load_file_arg
 

Macros

#define MAXPATHLEN   1024
 
#define O_ACCMODE   (O_RDONLY | O_WRONLY | O_RDWR)
 
#define DISABLE_RUBYGEMS   0
 
#define DEFAULT_RUBYGEMS_ENABLED   "enabled"
 
#define COMMA   ,
 
#define FEATURE_BIT(bit)   (1U << feature_##bit)
 
#define EACH_FEATURES(X, SEP)
 
#define EACH_DEBUG_FEATURES(X, SEP)
 
#define AMBIGUOUS_FEATURE_NAMES   0 /* no ambiguous feature names now */
 
#define DEFINE_FEATURE(bit)   feature_##bit
 
#define DEFINE_DEBUG_FEATURE(bit)   feature_debug_##bit
 
#define DEBUG_BIT(bit)   (1U << feature_debug_##bit)
 
#define DUMP_BIT(bit)   (1U << dump_##bit)
 
#define DEFINE_DUMP(bit)   dump_##bit
 
#define EACH_DUMPS(X, SEP)
 
#define src_encoding_index   GET_VM()->src_encoding_index
 
#define forbid_setid(s)   forbid_setid((s), opt)
 
#define M(shortopt, longopt, desc)
 
#define SHOW(m)   show_usage_line((m).str, (m).namelen, (m).secondlen, help)
 
#define rubylib_path_new   rb_str_new
 
#define UTF8_PATH   0
 
#define IF_UTF8_PATH(t, f)   f
 
#define INITIAL_LOAD_PATH_MARK   rb_intern_const("@gem_prelude_index")
 
#define RUBY_RELATIVE(path, len)   rubylib_path_new((path), (len))
 
#define PREFIX_PATH()   RUBY_RELATIVE(ruby_exec_prefix, exec_prefix_len)
 
#define NAME_MATCH_P(name, str, len)   ((len) < (int)sizeof(name) && name_match_p((name), (str), (len)))
 
#define UNSET_WHEN(name, bit, str, len)
 
#define SET_WHEN(name, bit, str, len)
 
#define LITERAL_NAME_ELEMENT(name)   #name
 
#define SET_FEATURE(bit)   if (NAME_MATCH_P(#bit, str, len)) {mask = FEATURE_BIT(bit); goto found;}
 
#define SET_WHEN_DEBUG(bit)   SET_WHEN(#bit, DEBUG_BIT(bit), str, len)
 
#define SET_WHEN_DUMP(bit)   SET_WHEN(#bit, DUMP_BIT(bit), str, len)
 
#define set_internal_encoding_once(opt, e, elen)   set_option_encoding_once("default_internal", &(opt)->intern.enc.name, (e), (elen))
 
#define set_external_encoding_once(opt, e, elen)   set_option_encoding_once("default_external", &(opt)->ext.enc.name, (e), (elen))
 
#define set_source_encoding_once(opt, e, elen)   set_option_encoding_once("source", &(opt)->src.enc.name, (e), (elen))
 
#define is_option_end(c, allow_hyphen)   (!(c) || ((allow_hyphen) && (c) == '-') || (c) == '=')
 
#define check_envopt(name, allow_envopt)
 
#define need_argument(name, s, needs_arg, next_arg)
 
#define is_option_with_arg(name, allow_hyphen, allow_envopt)   is_option_with_optarg(name, allow_hyphen, allow_envopt, Qtrue, Qtrue)
 
#define is_option_with_optarg(name, allow_hyphen, allow_envopt, needs_arg, next_arg)
 
#define set_encoding_part(type)
 
#define rb_progname   (GET_VM()->progname)
 
#define rb_orig_progname   (GET_VM()->orig_progname)
 
#define rb_define_readonly_boolean(name, val)   rb_define_virtual_variable((name), (val) ? true_value : false_value, 0)
 
#define SET_COMPILE_OPTION(h, o, name)
 
#define MODE_TO_LOAD   (O_RDONLY)
 

Typedefs

typedef struct ruby_cmdline_options ruby_cmdline_options_t
 

Enumerations

enum  feature_flag_bits {
  EACH_FEATURES =(DEFINE_FEATURE, COMMA), feature_debug_flag_first, feature_debug_flag_begin = feature_debug_flag_first - 1, EACH_DEBUG_FEATURES =(DEFINE_DEBUG_FEATURE, COMMA),
  feature_flag_count
}
 
enum  dump_flag_bits { dump_version_v, EACH_DUMPS =(DEFINE_DUMP, COMMA), dump_exit_bits }
 
enum  { COMPILATION_FEATURES, DEFAULT_FEATURES }
 

Functions

char * getenv ()
 
static void init_ids (ruby_cmdline_options_t *)
 
static ruby_cmdline_options_tcmdline_options_init (ruby_cmdline_options_t *opt)
 
static NODEload_file (VALUE, VALUE, int, ruby_cmdline_options_t *)
 
static void forbid_setid (const char *, ruby_cmdline_options_t *)
 
static void show_usage_line (const char *str, unsigned int namelen, unsigned int secondlen, int help)
 
static void usage (const char *name, int help)
 
static void push_include (const char *path, VALUE(*filter)(VALUE))
 
void ruby_push_include (const char *path, VALUE(*filter)(VALUE))
 
static VALUE identical_path (VALUE path)
 
static VALUE locale_path (VALUE path)
 
void ruby_incpush (const char *path)
 
static VALUE expand_include_path (VALUE path)
 
void ruby_incpush_expand (const char *path)
 
void ruby_init_loadpath_safe (int safe_level)
 
void ruby_init_loadpath (void)
 
static void add_modules (VALUE *req_list, const char *mod)
 
static void require_libraries (VALUE *req_list)
 
static const struct rb_blocktoplevel_context (rb_binding_t *bind)
 
static void process_sflag (int *sflag)
 
static long proc_options (long argc, char **argv, ruby_cmdline_options_t *opt, int envopt)
 
static void moreswitches (const char *s, ruby_cmdline_options_t *opt, int envopt)
 
static int name_match_p (const char *name, const char *str, size_t len)
 
static void feature_option (const char *str, int len, void *arg, const unsigned int enable)
 
static void enable_option (const char *str, int len, void *arg)
 
static void disable_option (const char *str, int len, void *arg)
 
static void debug_option (const char *str, int len, void *arg)
 
static void dump_option (const char *str, int len, void *arg)
 
static void set_option_encoding_once (const char *type, VALUE *name, const char *e, long elen)
 
static void ruby_init_prelude (void)
 
static int opt_enc_index (VALUE enc_name)
 
static VALUE false_value (void)
 
static VALUE true_value (void)
 
static VALUE uscore_get (void)
 
static VALUE rb_f_sub (int argc, VALUE *argv)
 
static VALUE rb_f_gsub (int argc, VALUE *argv)
 
static VALUE rb_f_chop (void)
 
static VALUE rb_f_chomp (int argc, VALUE *argv)
 
static VALUE process_options (int argc, char **argv, ruby_cmdline_options_t *opt)
 
static void warn_cr_in_shebang (const char *str, long len)
 
static VALUE load_file_internal (VALUE argp_v)
 
static VALUE open_load_file (VALUE fname_v, int *xflag)
 
static VALUE restore_load_file (VALUE arg)
 
void * rb_load_file (const char *fname)
 
void * rb_load_file_str (VALUE fname_v)
 
void * rb_parser_load_file (VALUE parser, VALUE fname_v)
 
static VALUE proc_argv0 (VALUE process)
 
static VALUE proc_setproctitle (VALUE process, VALUE title)
 
static void set_arg0 (VALUE val, ID id)
 
static VALUE external_str_new_cstr (const char *p)
 
void ruby_script (const char *name)
 Sets the current script name to this value. More...
 
void ruby_set_script_name (VALUE name)
 Sets the current script name to this value. More...
 
static void verbose_setter (VALUE val, ID id, void *data)
 
static VALUE opt_W_getter (ID id, void *data)
 
void ruby_prog_init (void)
 Defines built-in variables. More...
 
void ruby_set_argv (int argc, char **argv)
 
void * ruby_process_options (int argc, char **argv)
 
static void fill_standard_fds (void)
 
void ruby_sysinit (int *argc, char ***argv)
 Initializes the process for ruby(1). More...
 

Variables

struct {
   int   argc
 
   char **   argv
 
origarg
 
VALUE rb_argv0
 

Macro Definition Documentation

◆ AMBIGUOUS_FEATURE_NAMES

#define AMBIGUOUS_FEATURE_NAMES   0 /* no ambiguous feature names now */

Definition at line 80 of file ruby.c.

◆ check_envopt

#define check_envopt (   name,
  allow_envopt 
)
Value:
(((allow_envopt) || !envopt) ? (void)0 : \
rb_raise(rb_eRuntimeError, "invalid switch in RUBYOPT: --" name))
void rb_raise(VALUE exc, const char *fmt,...)
Definition: error.c:2207
VALUE rb_eRuntimeError
Definition: error.c:761
const char * name
Definition: nkf.c:208

◆ COMMA

#define COMMA   ,

Definition at line 66 of file ruby.c.

◆ DEBUG_BIT

#define DEBUG_BIT (   bit)    (1U << feature_debug_##bit)

Definition at line 91 of file ruby.c.

◆ DEFAULT_RUBYGEMS_ENABLED

#define DEFAULT_RUBYGEMS_ENABLED   "enabled"

Definition at line 63 of file ruby.c.

Referenced by usage().

◆ DEFINE_DEBUG_FEATURE

#define DEFINE_DEBUG_FEATURE (   bit)    feature_debug_##bit

Definition at line 82 of file ruby.c.

◆ DEFINE_DUMP

#define DEFINE_DUMP (   bit)    dump_##bit

Definition at line 94 of file ruby.c.

◆ DEFINE_FEATURE

#define DEFINE_FEATURE (   bit)    feature_##bit

Definition at line 81 of file ruby.c.

◆ DISABLE_RUBYGEMS

#define DISABLE_RUBYGEMS   0

Definition at line 58 of file ruby.c.

◆ DUMP_BIT

#define DUMP_BIT (   bit)    (1U << dump_##bit)

Definition at line 93 of file ruby.c.

Referenced by load_file_internal(), proc_options(), and process_options().

◆ EACH_DEBUG_FEATURES

#define EACH_DEBUG_FEATURES (   X,
  SEP 
)
Value:
X(frozen_string_literal) \
/* END OF DEBUG FEATURES */

Definition at line 77 of file ruby.c.

Referenced by debug_option().

◆ EACH_DUMPS

#define EACH_DUMPS (   X,
  SEP 
)
Value:
X(version) \
SEP \
X(copyright) \
SEP \
X(usage) \
SEP \
X(help) \
SEP \
X(yydebug) \
SEP \
X(syntax) \
SEP \
X(parsetree) \
SEP \
X(parsetree_with_comment) \
SEP \
X(insns) \
/* END OF DUMPS */
#define yydebug
Definition: ripper.c:438
static void usage(const char *name, int help)
Definition: ruby.c:200
int version
Definition: ossl_ssl.c:55

Definition at line 95 of file ruby.c.

Referenced by dump_option().

◆ EACH_FEATURES

#define EACH_FEATURES (   X,
  SEP 
)
Value:
X(gems) \
SEP \
X(did_you_mean) \
SEP \
X(rubyopt) \
SEP \
X(frozen_string_literal) \
/* END OF FEATURES */

Definition at line 68 of file ruby.c.

Referenced by feature_option().

◆ FEATURE_BIT

#define FEATURE_BIT (   bit)    (1U << feature_##bit)

Definition at line 67 of file ruby.c.

Referenced by process_options().

◆ forbid_setid

#define forbid_setid (   s)    forbid_setid((s), opt)

Definition at line 180 of file ruby.c.

Referenced by cmdline_options_init(), load_file_internal(), proc_options(), and process_options().

◆ IF_UTF8_PATH

#define IF_UTF8_PATH (   t,
  f 
)    f

Definition at line 415 of file ruby.c.

Referenced by process_options().

◆ INITIAL_LOAD_PATH_MARK

#define INITIAL_LOAD_PATH_MARK   rb_intern_const("@gem_prelude_index")

Definition at line 461 of file ruby.c.

Referenced by process_options(), and ruby_init_loadpath_safe().

◆ is_option_end

#define is_option_end (   c,
  allow_hyphen 
)    (!(c) || ((allow_hyphen) && (c) == '-') || (c) == '=')

◆ is_option_with_arg

#define is_option_with_arg (   name,
  allow_hyphen,
  allow_envopt 
)    is_option_with_optarg(name, allow_hyphen, allow_envopt, Qtrue, Qtrue)

Referenced by proc_options().

◆ is_option_with_optarg

#define is_option_with_optarg (   name,
  allow_hyphen,
  allow_envopt,
  needs_arg,
  next_arg 
)
Value:
(strncmp((name), s, n = sizeof(name) - 1) == 0 && is_option_end(s[n], (allow_hyphen)) ? \
(check_envopt(name, (allow_envopt)), s += n, \
need_argument(name, s, needs_arg, next_arg), 1) : 0)
#define check_envopt(name, allow_envopt)
#define is_option_end(c, allow_hyphen)
const char * name
Definition: nkf.c:208

Referenced by proc_options().

◆ LITERAL_NAME_ELEMENT

#define LITERAL_NAME_ELEMENT (   name)    #name

Definition at line 798 of file ruby.c.

Referenced by debug_option(), dump_option(), and feature_option().

◆ M

#define M (   shortopt,
  longopt,
  desc 
)
Value:
{ \
shortopt " " longopt " " desc, \
(unsigned short)sizeof(shortopt), \
(unsigned short)sizeof(longopt), \
}

Referenced by usage().

◆ MAXPATHLEN

#define MAXPATHLEN   1024

Definition at line 45 of file ruby.c.

Referenced by process_options(), and ruby_init_loadpath_safe().

◆ MODE_TO_LOAD

#define MODE_TO_LOAD   (O_RDONLY)

Referenced by open_load_file().

◆ NAME_MATCH_P

#define NAME_MATCH_P (   name,
  str,
  len 
)    ((len) < (int)sizeof(name) && name_match_p((name), (str), (len)))

Definition at line 783 of file ruby.c.

Referenced by feature_option().

◆ need_argument

#define need_argument (   name,
  s,
  needs_arg,
  next_arg 
)
Value:
((*(s) ? !*++(s) : (next_arg) && (!argc || !((s) = argv[1]) || (--argc, ++argv, 0))) && (needs_arg) ? \
rb_raise(rb_eRuntimeError, "missing argument for --" name) \
: (void)0)
void rb_raise(VALUE exc, const char *fmt,...)
Definition: error.c:2207
VALUE rb_eRuntimeError
Definition: error.c:761
int argc
Definition: ruby.c:183
const char * name
Definition: nkf.c:208
char ** argv
Definition: ruby.c:184

◆ O_ACCMODE

#define O_ACCMODE   (O_RDONLY | O_WRONLY | O_RDWR)

Definition at line 48 of file ruby.c.

◆ PREFIX_PATH

#define PREFIX_PATH ( )    RUBY_RELATIVE(ruby_exec_prefix, exec_prefix_len)

Referenced by ruby_init_loadpath_safe().

◆ rb_define_readonly_boolean

#define rb_define_readonly_boolean (   name,
  val 
)    rb_define_virtual_variable((name), (val) ? true_value : false_value, 0)

Definition at line 1346 of file ruby.c.

Referenced by process_options().

◆ rb_orig_progname

#define rb_orig_progname   (GET_VM()->orig_progname)

Definition at line 1331 of file ruby.c.

Referenced by proc_argv0(), ruby_script(), and ruby_set_script_name().

◆ rb_progname

#define rb_progname   (GET_VM()->progname)

◆ RUBY_RELATIVE

#define RUBY_RELATIVE (   path,
  len 
)    rubylib_path_new((path), (len))

Referenced by ruby_init_loadpath_safe().

◆ rubylib_path_new

#define rubylib_path_new   rb_str_new

Definition at line 270 of file ruby.c.

Referenced by push_include().

◆ SET_COMPILE_OPTION

#define SET_COMPILE_OPTION (   h,
  o,
  name 
)
Value:
static const struct st_features features[]
Definition: st.c:264
#define Qtrue
Definition: ruby.h:437
#define FEATURE_BIT(bit)
Definition: ruby.c:67
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val)
Definition: hash.c:1576
#define Qfalse
Definition: ruby.h:436
const char * name
Definition: nkf.c:208
#define ID2SYM(x)
Definition: ruby.h:383
#define rb_intern_const(str)
Definition: ruby.h:1756

Referenced by process_options().

◆ set_encoding_part

#define set_encoding_part (   type)
Value:
if (!(p = strchr(s, ':'))) { \
set_##type##_encoding_once(opt, s, 0); \
break; \
} \
else if (p > s) { \
set_##type##_encoding_once(opt, s, p-s); \
}
char * strchr(char *, char)

Referenced by proc_options().

◆ set_external_encoding_once

#define set_external_encoding_once (   opt,
  e,
  elen 
)    set_option_encoding_once("default_external", &(opt)->ext.enc.name, (e), (elen))

Definition at line 891 of file ruby.c.

Referenced by proc_options().

◆ SET_FEATURE

#define SET_FEATURE (   bit)    if (NAME_MATCH_P(#bit, str, len)) {mask = FEATURE_BIT(bit); goto found;}

Referenced by feature_option().

◆ set_internal_encoding_once

#define set_internal_encoding_once (   opt,
  e,
  elen 
)    set_option_encoding_once("default_internal", &(opt)->intern.enc.name, (e), (elen))

Definition at line 889 of file ruby.c.

Referenced by proc_options().

◆ set_source_encoding_once

#define set_source_encoding_once (   opt,
  e,
  elen 
)    set_option_encoding_once("source", &(opt)->src.enc.name, (e), (elen))

Definition at line 893 of file ruby.c.

Referenced by proc_options().

◆ SET_WHEN

#define SET_WHEN (   name,
  bit,
  str,
  len 
)
Value:
if (NAME_MATCH_P((name), (str), (len))) { \
*(unsigned int *)arg |= (bit); \
return; \
}
#define NAME_MATCH_P(name, str, len)
Definition: ruby.c:783
register unsigned int len
Definition: zonetab.h:51
const char * name
Definition: nkf.c:208

Definition at line 792 of file ruby.c.

◆ SET_WHEN_DEBUG

#define SET_WHEN_DEBUG (   bit)    SET_WHEN(#bit, DEBUG_BIT(bit), str, len)

Referenced by debug_option().

◆ SET_WHEN_DUMP

#define SET_WHEN_DUMP (   bit)    SET_WHEN(#bit, DUMP_BIT(bit), str, len)

Referenced by dump_option().

◆ SHOW

#define SHOW (   m)    show_usage_line((m).str, (m).namelen, (m).secondlen, help)

Referenced by usage().

◆ src_encoding_index

#define src_encoding_index   GET_VM()->src_encoding_index

Definition at line 149 of file ruby.c.

Referenced by cmdline_options_init(), load_file_internal(), and process_options().

◆ UNSET_WHEN

#define UNSET_WHEN (   name,
  bit,
  str,
  len 
)
Value:
if (NAME_MATCH_P((name), (str), (len))) { \
*(unsigned int *)arg &= ~(bit); \
return; \
}
#define NAME_MATCH_P(name, str, len)
Definition: ruby.c:783
register unsigned int len
Definition: zonetab.h:51
const char * name
Definition: nkf.c:208

Definition at line 786 of file ruby.c.

◆ UTF8_PATH

#define UTF8_PATH   0

Definition at line 410 of file ruby.c.

Typedef Documentation

◆ ruby_cmdline_options_t

Definition at line 122 of file ruby.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
COMPILATION_FEATURES 
DEFAULT_FEATURES 

Definition at line 151 of file ruby.c.

◆ dump_flag_bits

Enumerator
dump_version_v 
EACH_DUMPS 
dump_exit_bits 

Definition at line 114 of file ruby.c.

◆ feature_flag_bits

Enumerator
EACH_FEATURES 
feature_debug_flag_first 
feature_debug_flag_begin 
EACH_DEBUG_FEATURES 
feature_flag_count 

Definition at line 83 of file ruby.c.

Function Documentation

◆ add_modules()

static void add_modules ( VALUE req_list,
const char *  mod 
)
static

Definition at line 613 of file ruby.c.

References list, rb_ary_new(), rb_ary_push(), rb_str_new2, RBASIC_CLEAR_CLASS, and ruby_cmdline_options::req_list.

Referenced by proc_options().

◆ cmdline_options_init()

static ruby_cmdline_options_t* cmdline_options_init ( ruby_cmdline_options_t opt)
static

◆ debug_option()

static void debug_option ( const char *  str,
int  len,
void *  arg 
)
static

Definition at line 854 of file ruby.c.

References EACH_DEBUG_FEATURES, list, LITERAL_NAME_ELEMENT, rb_warn(), SET_WHEN_DEBUG, and strlen().

Referenced by proc_options().

◆ disable_option()

static void disable_option ( const char *  str,
int  len,
void *  arg 
)
static

Definition at line 848 of file ruby.c.

References feature_option().

Referenced by proc_options().

◆ dump_option()

static void dump_option ( const char *  str,
int  len,
void *  arg 
)
static

Definition at line 864 of file ruby.c.

References EACH_DUMPS, list, LITERAL_NAME_ELEMENT, rb_warn(), SET_WHEN_DUMP, and strlen().

Referenced by proc_options().

◆ enable_option()

static void enable_option ( const char *  str,
int  len,
void *  arg 
)
static

Definition at line 842 of file ruby.c.

References feature_option().

Referenced by proc_options().

◆ expand_include_path()

static VALUE expand_include_path ( VALUE  path)
static

Definition at line 360 of file ruby.c.

References Qnil, rb_file_expand_path(), and RSTRING_PTR.

Referenced by ruby_incpush_expand(), and ruby_init_loadpath_safe().

◆ external_str_new_cstr()

static VALUE external_str_new_cstr ( const char *  p)
inlinestatic

◆ false_value()

static VALUE false_value ( void  )
static

Definition at line 1335 of file ruby.c.

References Qfalse.

◆ feature_option()

static void feature_option ( const char *  str,
int  len,
void *  arg,
const unsigned int  enable 
)
static

◆ fill_standard_fds()

static void fill_standard_fds ( void  )
static

Definition at line 2220 of file ruby.c.

References dup2(), errno, fstat, and stat.

Referenced by ruby_sysinit().

◆ forbid_setid()

static void forbid_setid ( const char *  s,
ruby_cmdline_options_t opt 
)
static

◆ getenv()

char* getenv ( )

◆ identical_path()

static VALUE identical_path ( VALUE  path)
static

Definition at line 342 of file ruby.c.

Referenced by ruby_init_loadpath_safe().

◆ init_ids()

static void init_ids ( ruby_cmdline_options_t opt)
static

◆ load_file()

static NODE * load_file ( VALUE  parser,
VALUE  fname,
int  script,
ruby_cmdline_options_t opt 
)
static

◆ load_file_internal()

static VALUE load_file_internal ( VALUE  argp_v)
static

◆ locale_path()

static VALUE locale_path ( VALUE  path)
static

Definition at line 347 of file ruby.c.

References rb_enc_associate(), and rb_locale_encoding().

Referenced by ruby_incpush().

◆ moreswitches()

static void moreswitches ( const char *  s,
ruby_cmdline_options_t opt,
int  envopt 
)
static

◆ name_match_p()

static int name_match_p ( const char *  name,
const char *  str,
size_t  len 
)
static

Definition at line 766 of file ruby.c.

References ISALNUM, ruby_cmdline_options::name, and TOLOWER.

◆ open_load_file()

static VALUE open_load_file ( VALUE  fname_v,
int *  xflag 
)
static

◆ opt_enc_index()

static int opt_enc_index ( VALUE  enc_name)
static

◆ opt_W_getter()

static VALUE opt_W_getter ( ID  id,
void *  data 
)
static

Definition at line 2138 of file ruby.c.

References INT2FIX, Qfalse, Qnil, and Qtrue.

Referenced by ruby_prog_init().

◆ proc_argv0()

static VALUE proc_argv0 ( VALUE  process)
static

Definition at line 2026 of file ruby.c.

References rb_orig_progname.

Referenced by ruby_prog_init().

◆ proc_options()

static long proc_options ( long  argc,
char **  argv,
ruby_cmdline_options_t opt,
int  envopt 
)
static

◆ proc_setproctitle()

static VALUE proc_setproctitle ( VALUE  process,
VALUE  title 
)
static

Definition at line 2049 of file ruby.c.

References RSTRING_LENINT, RSTRING_PTR, setproctitle(), and StringValue.

Referenced by ruby_prog_init(), and set_arg0().

◆ process_options()

static VALUE process_options ( int  argc,
char **  argv,
ruby_cmdline_options_t opt 
)
static

Definition at line 1438 of file ruby.c.

References COMPILATION_FEATURES, DEFAULT_FEATURES, dln_find_file_r, ruby_cmdline_options::do_line, ruby_cmdline_options::do_loop, ruby_cmdline_options::do_print, ruby_cmdline_options::do_search, ruby_cmdline_options::do_split, ruby_cmdline_options::dump, DUMP_BIT, dump_exit_bits, ruby_cmdline_options::e_script, ruby_cmdline_options::enc, ruby_cmdline_options::ext, FEATURE_BIT, ruby_cmdline_options::features, forbid_setid, GET_VM, GetBindingPtr, getenv(), IF_UTF8_PATH, Init_enc(), Init_ext(), INITIAL_LOAD_PATH_MARK, ruby_cmdline_options::intern, load_file(), mark(), MAXPATHLEN, moreswitches(), opt_enc_index(), origarg, PATH_ENV, proc_options(), process_sflag(), Qfalse, Qnil, Qtrue, RARRAY_AREF, RARRAY_ASET, RARRAY_LEN, rb_attr_get(), rb_cISeq, rb_cObject, rb_const_get(), rb_default_internal_encoding(), rb_define_global_function(), rb_define_module(), rb_define_readonly_boolean, rb_enc_associate(), rb_enc_from_encoding(), rb_enc_from_index(), rb_enc_set_default_external(), rb_enc_set_default_internal(), rb_f_chomp(), rb_f_chop(), rb_f_gsub(), rb_f_sub(), rb_funcallv, rb_hash_new(), rb_intern, rb_intern_const, rb_io_flush(), rb_io_write(), rb_iseq_disasm(), rb_iseq_new_main(), rb_ivar_set(), rb_locale_encoding(), rb_obj_freeze(), rb_parser_append_print(), rb_parser_compile_string(), rb_parser_dump_tree(), rb_parser_new(), rb_parser_set_context(), rb_parser_set_yydebug(), rb_parser_while_loop(), rb_progname, rb_realpath_internal(), rb_set_safe_level(), rb_stdio_set_default_encoding(), rb_stdout, rb_str_conv_enc(), rb_str_dup(), rb_str_new_cstr(), rb_utf8_encoding(), rb_warning(), ruby_cmdline_options::req_list, require_libraries(), RSTRING_PTR, ruby_gc_set_params(), ruby_init_loadpath_safe(), ruby_init_prelude(), ruby_set_argv(), ruby_set_script_name(), ruby_show_copyright, ruby_show_version(), ruby_cmdline_options::safe_level, ruby_cmdline_options::script, ruby_cmdline_options::script_name, SET_COMPILE_OPTION, ruby_cmdline_options::sflag, ruby_cmdline_options::src, src_encoding_index, toplevel_context(), TRUE, usage(), ruby_cmdline_options::verbose, version, vm_block_iseq(), ruby_cmdline_options::xflag, and yydebug.

Referenced by ruby_process_options().

◆ process_sflag()

static void process_sflag ( int *  sflag)
static

◆ push_include()

static void push_include ( const char *  path,
VALUE(*)(VALUE filter 
)
static

◆ rb_f_chomp()

static VALUE rb_f_chomp ( int  argc,
VALUE argv 
)
static

Definition at line 1430 of file ruby.c.

References rb_funcall_passing_block(), rb_intern, rb_lastline_set(), and uscore_get().

Referenced by process_options().

◆ rb_f_chop()

static VALUE rb_f_chop ( void  )
static

Definition at line 1410 of file ruby.c.

References rb_funcall_passing_block(), rb_intern, rb_lastline_set(), and uscore_get().

Referenced by process_options().

◆ rb_f_gsub()

static VALUE rb_f_gsub ( int  argc,
VALUE argv 
)
static

Definition at line 1392 of file ruby.c.

References rb_funcall_passing_block(), rb_intern, rb_lastline_set(), and uscore_get().

Referenced by process_options().

◆ rb_f_sub()

static VALUE rb_f_sub ( int  argc,
VALUE argv 
)
static

Definition at line 1373 of file ruby.c.

References rb_funcall_passing_block(), rb_intern, rb_lastline_set(), and uscore_get().

Referenced by process_options().

◆ rb_load_file()

void* rb_load_file ( const char *  fname)

Definition at line 1992 of file ruby.c.

References rb_load_file_str(), and rb_str_new_cstr().

◆ rb_load_file_str()

void* rb_load_file_str ( VALUE  fname_v)

Definition at line 1999 of file ruby.c.

References cmdline_options_init(), load_file(), load_file_arg::opt, and rb_parser_new().

Referenced by rb_load_file().

◆ rb_parser_load_file()

void* rb_parser_load_file ( VALUE  parser,
VALUE  fname_v 
)

Definition at line 2007 of file ruby.c.

References cmdline_options_init(), load_file(), and load_file_arg::opt.

Referenced by rb_load_internal0().

◆ require_libraries()

static void require_libraries ( VALUE req_list)
static

◆ restore_load_file()

static VALUE restore_load_file ( VALUE  arg)
static

Definition at line 1951 of file ruby.c.

References f, load_file_arg::f, Qnil, rb_define_global_const(), rb_io_close(), rb_stdin, and load_file_arg::script.

Referenced by load_file().

◆ ruby_incpush_expand()

void ruby_incpush_expand ( const char *  path)

Definition at line 371 of file ruby.c.

References expand_include_path(), ruby_push_include(), and TRUE.

Referenced by proc_options().

◆ ruby_init_loadpath_safe()

void ruby_init_loadpath_safe ( int  safe_level)

◆ ruby_init_prelude()

static void ruby_init_prelude ( void  )
static

Definition at line 1309 of file ruby.c.

References Init_prelude(), rb_cObject, rb_const_remove(), and rb_intern_const.

Referenced by process_options().

◆ ruby_push_include()

void ruby_push_include ( const char *  path,
VALUE(*)(VALUE filter 
)

Definition at line 334 of file ruby.c.

References push_include().

Referenced by ruby_incpush(), ruby_incpush_expand(), and ruby_init_loadpath_safe().

◆ set_arg0()

static void set_arg0 ( VALUE  val,
ID  id 
)
static

◆ set_option_encoding_once()

static void set_option_encoding_once ( const char *  type,
VALUE name,
const char *  e,
long  elen 
)
static

Definition at line 874 of file ruby.c.

References INT2FIX, PRIsVALUE, rb_eRuntimeError, rb_funcall(), rb_intern, rb_raise(), rb_str_new(), and strlen().

◆ show_usage_line()

static void show_usage_line ( const char *  str,
unsigned int  namelen,
unsigned int  secondlen,
int  help 
)
static

Definition at line 188 of file ruby.c.

◆ toplevel_context()

static const struct rb_block* toplevel_context ( rb_binding_t bind)
static

Definition at line 647 of file ruby.c.

References rb_binding_t::block.

Referenced by process_options().

◆ true_value()

static VALUE true_value ( void  )
static

Definition at line 1341 of file ruby.c.

References Qtrue.

◆ usage()

static void usage ( const char *  name,
int  help 
)
static

Definition at line 200 of file ruby.c.

References DEFAULT_RUBYGEMS_ENABLED, M, numberof, and SHOW.

Referenced by proc_options(), and process_options().

◆ uscore_get()

static VALUE uscore_get ( void  )
static

◆ verbose_setter()

static void verbose_setter ( VALUE  val,
ID  id,
void *  data 
)
static

Definition at line 2131 of file ruby.c.

References Qtrue, RTEST, and val.

Referenced by ruby_prog_init().

◆ warn_cr_in_shebang()

static void warn_cr_in_shebang ( const char *  str,
long  len 
)
static

Definition at line 1732 of file ruby.c.

References rb_warn().

Referenced by load_file_internal().

Variable Documentation

◆ argc

int argc

Definition at line 183 of file ruby.c.

Referenced by addrinfo_s_udp(), apply2files(), argf_block_call_i(), argf_block_call_line_i(), argf_forward_call(), argf_getpartial(), ary_ensure_room_for_unshift(), ary_memcpy0(), BigDecimal_s_allocate(), build_postexe_iseq(), call_cfunc_m1(), collect_all(), collect_i(), compat_init_setproctitle(), core_hash_merge(), count_iter_i(), cycle_i(), date_s_valid_commercial_p(), dir_globs(), drop_i(), drop_while_i(), each_val_i(), each_with_index_i(), enum_zip(), enumerator_initialize(), env_values_at(), exit_initialize(), extract_raise_opts(), fdbm_values_at(), fgdbm_values_at(), find_all_i(), find_i(), find_index_iter_i(), flat_map_i(), flock_winnt(), fsdbm_values_at(), function_call(), grep_iter_i(), group_by_i(), gzfile_wrap(), Init_openssl(), initialize(), invoke_iseq_block_from_c(), io_getch(), io_wait_readwrite(), iseq_build_from_ary_body(), iseq_compile_each(), iseq_optimize(), lazy_add_method(), lazy_to_enum(), lazy_uniq_func(), lazy_uniq_iter(), lazy_zip(), main(), match_values_at(), max_by_i(), member_i(), method_missing(), min_by_i(), minmax_by_i(), mInteger_to_json(), moreswitches(), new_insn_body(), new_insn_core(), nucomp_s_alloc(), num_step_size(), nurat_s_alloc(), obj_to_enum(), old_to_new(), open_key_args(), ossl_cipher_is_authenticated(), parser_compile_error(), partition_i(), pipe_open_s(), proc_options(), process_sflag(), rand_range(), rb_add_method_cfunc(), rb_apply(), rb_ary_concat_multi(), rb_ary_zip(), rb_block_call(), rb_block_lambda(), rb_call(), rb_check_argv(), rb_check_arity(), rb_check_block_call(), rb_check_funcall_with_hook(), rb_enumeratorize(), rb_exec_fillarg(), rb_execarg_commandline(), rb_f_kill(), rb_f_p(), rb_f_p_internal(), rb_f_send(), rb_file_chmod(), rb_get_values_at(), rb_hash_fetch_values(), rb_hash_s_create(), rb_hash_values_at(), rb_io_print(), rb_io_puts(), rb_io_s_foreach(), rb_io_s_popen(), rb_iseq_disasm(), rb_lambda_call(), rb_longjmp(), rb_mod_attr_accessor(), rb_mod_attr_reader(), rb_mod_attr_writer(), rb_mod_include(), rb_mod_modfunc(), rb_mod_prepend(), rb_mod_remove_method(), rb_mod_undef_method(), rb_obj_dig(), rb_obj_extend(), rb_obj_info_dump(), rb_reg_s_union(), rb_scan_args(), rb_str_concat_multi(), rb_str_count(), rb_str_delete_bang(), rb_str_encode(), rb_str_end_with(), rb_str_format(), rb_str_prepend_multi(), rb_str_slice_bang(), rb_str_squeeze_bang(), rb_str_start_with(), rb_struct_initialize_m(), rb_struct_s_def(), rb_vmdebug_stack_dump_th(), rb_w32_asynchronize(), reject_i(), ruby_set_argv(), ruby_sysinit(), set_const_visibility(), set_method_visibility(), setup_args(), setup_method_cfunc_struct(), setup_narg(), sock_initialize(), sort_by_i(), take_i(), take_while_i(), tracepoint_new_s(), uniq_iter(), valid_civil_sub(), valid_commercial_sub(), valid_jd_sub(), valid_ordinal_sub(), vm_bind_update_env(), vm_call0(), vm_call0_cfunc_with_frame(), vm_call_bmethod(), vm_call_cfunc_with_frame(), vm_call_method_missing(), vm_call_opt_call(), vm_invoke_ifunc_block(), vm_invoke_symbol_block(), vm_yield_setup_args(), weeknumber_v(), with_gvl_callback(), zip_ary(), and zip_i().

◆ argv

char** argv

Definition at line 184 of file ruby.c.

Referenced by addrinfo_s_udp(), asn1time_to_time(), BigDecimal_s_allocate(), call_cfunc_m1(), call_trace_func(), collect_all(), collect_i(), count_iter_i(), cycle_i(), date_s_valid_commercial_p(), drop_i(), each_pair_i_fast(), each_with_index_i(), exit_initialize(), ffi_prep_args(), find_index_iter_i(), flat_map_i(), gzfile_wrap(), Init_openssl(), io_getch(), iseq_build_from_ary_body(), lazy_zip_func(), lazyenum_yield_values(), member_i(), mInteger_to_json(), moreswitches(), new_insn_body(), new_insn_core(), nucomp_s_alloc(), num_step_size(), nurat_s_alloc(), old_to_new(), ossl_cipher_is_authenticated(), parser_compile_error(), proc_exec_cmd(), proc_options(), process_sflag(), rand_range(), rb_apply(), rb_ary_dig(), rb_block_call(), rb_block_lambda(), rb_call(), rb_check_block_call(), rb_check_deadlock(), rb_check_funcall_with_hook(), rb_enumeratorize(), rb_execarg_commandline(), rb_execarg_init(), rb_f_send(), rb_fiber_start(), rb_fiddle_new_function(), rb_file_chmod(), rb_funcall(), rb_hash_dig(), rb_lambda_call(), rb_longjmp(), rb_name_error(), rb_name_error_str(), rb_obj_dig(), rb_obj_info_dump(), rb_spawn_process(), rb_str_encode(), rb_str_format(), rb_struct_dig(), rb_struct_s_def(), rb_threadptr_signal_exit(), rb_threadptr_signal_raise(), rb_w32_asynchronize(), rb_yield_values(), ruby_sysinit(), save_env_i(), security(), send_internal(), set_argv(), sock_initialize(), take_i(), take_while_i(), uniq_iter(), valid_civil_sub(), valid_commercial_sub(), valid_jd_sub(), valid_ordinal_sub(), vm_bind_update_env(), vm_call0(), vm_call_bmethod(), vm_call_cfunc_with_frame(), vm_call_iseq_setup_normal(), vm_call_iseq_setup_tailcall(), vm_call_method_missing(), vm_call_method_nome(), vm_call_opt_call(), w32_aspawn_flags(), weeknumber_v(), zip_ary(), and zip_i().

◆ origarg

struct { ... } origarg

◆ rb_argv0

VALUE rb_argv0

Definition at line 1332 of file ruby.c.