Ruby
2.4.2p198(2017-09-14revision59899)
|
#include "internal.h"
#include "ruby/re.h"
#include "id.h"
#include <math.h>
#include <stdarg.h>
#include "vsnprintf.c"
Go to the source code of this file.
Data Structures | |
struct | rb_printf_buffer_extra |
Macros | |
#define | BIT_DIGITS(N) (((N)*146)/485 + 1) /* log2(10) =~ 146/485 */ |
#define | FNONE 0 |
#define | FSHARP 1 |
#define | FMINUS 2 |
#define | FPLUS 4 |
#define | FZERO 8 |
#define | FSPACE 16 |
#define | FWIDTH 32 |
#define | FPREC 64 |
#define | FPREC0 128 |
#define | CHECK(l) |
#define | PUSH(s, l) |
#define | PUSH_(s, l) |
#define | FILL(c, l) |
#define | FILL_(c, l) |
#define | GETARG() |
#define | GETNEXTARG() |
#define | GETPOSARG(n) |
#define | GETNTHARG(nth) (((nth) >= argc) ? (rb_raise(rb_eArgError, "too few arguments"), 0) : argv[(nth)]) |
#define | CHECKNAMEARG(name, len, enc) |
#define | GETNUM(n, val) |
#define | GETASTER(val) |
#define | CHECK_FOR_WIDTH(f) |
#define | CHECK_FOR_FLAGS(f) |
#define | FILE rb_printf_buffer |
#define | __sbuf rb_printf_sbuf |
#define | __sFILE rb_printf_sfile |
#define | FLOATING_POINT 1 |
#define | BSD__dtoa ruby_dtoa |
#define | BSD__hdtoa ruby_hdtoa |
#define | PRI_EXTRA_MARK RUBY_PRI_VALUE_MARK |
#define | lower_hexdigits (ruby_hexdigits+0) |
#define | upper_hexdigits (ruby_hexdigits+16) |
#define | LITERAL(str) (*sz = rb_strlen_lit(str), str) |
#define | f buffer.base |
#define | f buffer.base |
Functions | |
static void | fmt_setup (char *, size_t, int, int, int, int) |
static char | sign_bits (int base, const char *p) |
static const char * | get_num (const char *p, const char *end, rb_encoding *enc, int *valp) |
static void | check_next_arg (int posarg, int nextarg) |
static void | check_pos_arg (int posarg, int n) |
static void | check_name_arg (int posarg, const char *name, int len, rb_encoding *enc) |
static VALUE | get_hash (volatile VALUE *hash, int argc, const VALUE *argv) |
VALUE | rb_f_sprintf (int argc, const VALUE *argv) |
VALUE | rb_str_format (int argc, const VALUE *argv, VALUE fmt) |
int | ruby_vsnprintf (char *str, size_t n, const char *fmt, va_list ap) |
int | ruby_snprintf (char *str, size_t n, char const *fmt,...) |
static int | ruby__sfvwrite (register rb_printf_buffer *fp, register struct __suio *uio) |
static const char * | ruby__sfvextra (rb_printf_buffer *fp, size_t valsize, void *valp, long *sz, int sign) |
VALUE | rb_enc_vsprintf (rb_encoding *enc, const char *fmt, va_list ap) |
VALUE | rb_enc_sprintf (rb_encoding *enc, const char *format,...) |
VALUE | rb_vsprintf (const char *fmt, va_list ap) |
VALUE | rb_sprintf (const char *format,...) |
VALUE | rb_str_vcatf (VALUE str, const char *fmt, va_list ap) |
VALUE | rb_str_catf (VALUE str, const char *format,...) |
Definition at line 24 of file sprintf.c.
Referenced by rb_str_format().
#define BSD__dtoa ruby_dtoa |
Definition at line 1256 of file sprintf.c.
Referenced by BSD_vfprintf().
#define BSD__hdtoa ruby_hdtoa |
Definition at line 1257 of file sprintf.c.
Referenced by BSD_vfprintf().
#define CHECK | ( | l | ) |
Definition at line 56 of file sprintf.c.
Referenced by rb_str_format(), and ruby__sfvwrite().
#define CHECK_FOR_FLAGS | ( | f | ) |
Referenced by rb_str_format().
#define CHECK_FOR_WIDTH | ( | f | ) |
Referenced by rb_str_format().
#define f buffer.base |
Referenced by assign_to_ffi_arg(), backref_match_at_nested_level(), base64_conv(), BigDecimal_divremain(), BigDecimal_mode(), BigDecimal_remainder(), BigDecimal_to_s(), BigDecimal_version(), BigDecimalCmp(), broken_getc(), cap_ungetc(), check_bom(), cont_restore_1(), d_lite_plus(), date_s_commercial(), date_s_valid_commercial_p(), datetime_s_commercial(), datetime_to_datetime(), decode_day(), div_df(), expect_numeric(), f_complex_new_bang2(), f_rational_new_bang1(), f_signbit(), ffi_call(), ffi_prep_args(), ffi_prep_args_SYSV(), flo_ceil(), flo_floor(), flo_negative_p(), flo_positive_p(), flo_round(), flo_to_i(), float_decode_internal(), float_to_r(), get_special_folder(), h_conv(), heap_extend_pages(), hex_getc(), init_env(), iseqw_s_compile_file(), kanji_convert(), lgamma_r(), load_file_internal(), main(), make_tab_empty(), mime_begin(), mime_begin_strict(), mime_getc(), mime_ungetc_buf(), nfc_getc(), nfc_ungetc(), num_step(), numchar_getc(), numchar_ungetc(), onig_set_verb_warn_func(), onig_set_warn_func(), open_load_file(), ossl_engine_set_default(), ossl_x509stctx_set_flags(), ossl_x509store_set_flags(), pack_pack(), parse_time(), parse_time2_cb(), prep_stdio(), rand_range(), rb_ary_sum(), rb_class_foreach_subclass(), rb_convert_to_integer(), rb_enc_vsprintf(), rb_feature_p(), rb_fiddle_ptr_initialize(), rb_fiddle_ptr_s_malloc(), rb_file_s_basename(), rb_file_s_rename(), rb_find_file_ext_safe(), rb_find_file_safe(), rb_flt_rationalize(), rb_int_ceil(), rb_int_floor(), rb_int_round(), rb_int_truncate(), rb_stat(), rb_str_justify(), rb_str_vcatf(), rb_w32_wrap_io_handle(), readline_s_set_input(), readline_s_set_output(), reparse_symlink(), restore_load_file(), round(), round_half_down(), round_half_even(), round_half_up(), ruby_enc_find_basename(), ruby_vsnprintf(), set_iconv(), set_sub_anchor(), SHA256_Init(), SHA256_Transform(), SHA512_Init(), SHA512_Transform(), sum_iter(), test_fn(), tgamma(), time_timespec(), trans_sweep(), url_ungetc(), VpInternalRound(), VpSqrt(), VpVtoD(), and winnt_stat().
#define f buffer.base |
#define FILL | ( | c, | |
l | |||
) |
Definition at line 76 of file sprintf.c.
Referenced by rb_str_format().
#define FILL_ | ( | c, | |
l | |||
) |
Definition at line 81 of file sprintf.c.
Referenced by rb_str_format().
#define FMINUS 2 |
Definition at line 48 of file sprintf.c.
Referenced by fmt_setup(), and rb_str_format().
#define FNONE 0 |
Definition at line 46 of file sprintf.c.
Referenced by rb_str_format().
#define FPLUS 4 |
Definition at line 49 of file sprintf.c.
Referenced by fmt_setup(), and rb_str_format().
#define FPREC 64 |
Definition at line 53 of file sprintf.c.
Referenced by fmt_setup(), and rb_str_format().
#define FPREC0 128 |
Definition at line 54 of file sprintf.c.
Referenced by rb_str_format().
#define FSHARP 1 |
Definition at line 47 of file sprintf.c.
Referenced by fmt_setup(), and rb_str_format().
#define FSPACE 16 |
Definition at line 51 of file sprintf.c.
Referenced by fmt_setup(), and rb_str_format().
#define FWIDTH 32 |
Definition at line 52 of file sprintf.c.
Referenced by fmt_setup(), and rb_str_format().
#define FZERO 8 |
Definition at line 50 of file sprintf.c.
Referenced by fmt_setup(), and rb_str_format().
#define GETARG | ( | ) |
Definition at line 86 of file sprintf.c.
Referenced by rb_str_format().
#define GETASTER | ( | val | ) |
Definition at line 108 of file sprintf.c.
Referenced by rb_str_format().
#define GETNEXTARG | ( | ) |
#define GETNTHARG | ( | nth | ) | (((nth) >= argc) ? (rb_raise(rb_eArgError, "too few arguments"), 0) : argv[(nth)]) |
Definition at line 97 of file sprintf.c.
Referenced by rb_f_sprintf().
#define GETNUM | ( | n, | |
val | |||
) |
Definition at line 104 of file sprintf.c.
Referenced by rb_str_format().
#define GETPOSARG | ( | n | ) |
Definition at line 93 of file sprintf.c.
Referenced by rb_str_format().
#define LITERAL | ( | str | ) | (*sz = rb_strlen_lit(str), str) |
Referenced by ruby__sfvextra().
#define lower_hexdigits (ruby_hexdigits+0) |
#define PRI_EXTRA_MARK RUBY_PRI_VALUE_MARK |
Definition at line 1259 of file sprintf.c.
Referenced by BSD_vfprintf().
#define PUSH | ( | s, | |
l | |||
) |
Definition at line 66 of file sprintf.c.
Referenced by rb_str_format().
#define PUSH_ | ( | s, | |
l | |||
) |
Definition at line 71 of file sprintf.c.
Referenced by rb_str_format().
#define upper_hexdigits (ruby_hexdigits+16) |
|
static |
Definition at line 167 of file sprintf.c.
References rb_eArgError, and rb_enc_raise().
|
static |
Definition at line 142 of file sprintf.c.
References rb_eArgError, and rb_raise().
|
static |
Definition at line 153 of file sprintf.c.
References rb_eArgError, and rb_raise().
|
static |
Definition at line 178 of file sprintf.c.
References hash(), NIL_P, Qundef, rb_check_hash_type(), rb_eArgError, and rb_raise().
Referenced by rb_str_format().
|
static |
Definition at line 123 of file sprintf.c.
References MUL_OVERFLOW_INT_P, NULL, rb_eArgError, rb_enc_isdigit, and rb_raise().
VALUE rb_enc_sprintf | ( | rb_encoding * | enc, |
const char * | format, | ||
... | |||
) |
Definition at line 1421 of file sprintf.c.
References rb_enc_vsprintf(), and result.
Referenced by d_lite_to_s(), enc_inspect(), location_format(), mk_inspect(), of2str(), and str_upto_each().
VALUE rb_enc_vsprintf | ( | rb_encoding * | enc, |
const char * | fmt, | ||
va_list | ap | ||
) |
Definition at line 1388 of file sprintf.c.
References __SSTR, __SWR, BSD_vfprintf(), f, rb_cString, rb_eArgError, rb_enc_associate(), rb_enc_mbminlen, rb_enc_name, rb_raise(), rb_str_buf_new(), rb_str_resize(), RBASIC_CLEAR_CLASS, RBASIC_SET_CLASS_RAW, result, RSTRING_PTR, ruby__sfvextra(), ruby__sfvwrite(), and rb_printf_buffer_extra::value.
Referenced by enc_raise(), rb_enc_raise(), rb_enc_sprintf(), rb_loaderror(), rb_loaderror_with_path(), and rb_vsprintf().
Definition at line 455 of file sprintf.c.
References GETNTHARG, and rb_str_format().
Referenced by InitVM_Object(), rb_f_printf(), rb_io_printf(), and syslog_write().
Definition at line 1440 of file sprintf.c.
References rb_vsprintf(), and result.
Referenced by addrinfo_inspect(), econv_inspect(), envix(), error_pos_str(), esignal_init(), etc_systmpdir(), feature_option(), folerecord_inspect(), foletypelib_version(), folevariable_inspect(), gc_profile_dump_on(), Init_Bignum(), Init_dbm(), init_env(), insn_data_to_s_detail(), inspect_enumerator(), io_fillbuf(), iow_inspect(), iseq_compile_each(), iseq_inspect(), iseqw_inspect(), load_encoding(), make_econv_exception(), make_inspectname(), make_name_for_block(), make_temporary_path(), match_inspect(), mSyslog_inspect(), oldbt_print_to(), ole_cp2encoding(), ole_search_handler_method(), ossl_engine_inspect(), ossl_x509_inspect(), parser_set_encode(), path_inspect(), proc_to_s_(), pst_inspect(), pty_open(), raise_from_check(), raise_zlib_error(), rb_any_to_s(), rb_arity_error_new(), rb_attr(), rb_econv_init_by_convpath(), rb_f_global_variables(), rb_fiddle_ptr_inspect(), rb_insn_operand_intern(), rb_keyword_error_new(), rb_obj_inspect(), rb_profile_frame_classpath(), rb_profile_frame_full_label(), rb_profile_frame_qualified_method_name(), rb_signo2signm(), rb_stat_inspect(), rb_thread_current_status(), rb_thread_inspect(), rb_threadptr_error_print(), register_label(), rescue_callback(), rsock_syserr_fail_host_port(), rsock_syserr_fail_path(), rsock_syserr_fail_raddrinfo(), ruby_setenv(), setup_exception(), show_bitstack(), sockopt_inspect(), strscan_inspect(), tracepoint_inspect(), unexpected_type(), and wmap_inspect().
Definition at line 1480 of file sprintf.c.
References rb_str_vcatf().
Referenced by addrinfo_inspect(), debug_deadlock_check(), dump_node(), econv_description(), err_vcatf(), flo_to_s(), insn_data_to_s_detail(), inspect_byte(), inspect_errno(), inspect_i(), inspect_int(), inspect_timeval_as_interval(), location_format(), make_econv_exception(), make_inspectname(), match_inspect(), method_inspect(), oldbt_print_to(), pst_message(), rb_if_indextoname(), rb_io_inspect(), rb_iseq_disasm(), rb_iseq_disasm_insn(), rb_stat_inspect(), rb_sys_enc_warning(), rb_sys_warning(), rb_thread_inspect(), rsock_inspect_sockaddr(), show_bitstack(), sockopt_inspect(), syserr_initialize(), and trace_lex_state().
Definition at line 461 of file sprintf.c.
References argc, argv, BIGNUM_NEGATIVE_P, BIT_DIGITS, buf, CHAR_BIT, CHECK, CHECK_FOR_FLAGS, CHECK_FOR_WIDTH, CHECKNAMEARG, ENC_CODERANGE_7BIT, ENC_CODERANGE_BROKEN, ENC_CODERANGE_SET, ENC_CODERANGE_UNKNOWN, ffs(), FILL, FILL_, FIX2LONG, FIXABLE, FIXNUM_P, float_value(), FMINUS, fmt_setup(), FNONE, FPLUS, FPREC, FPREC0, FSHARP, FSPACE, FWIDTH, FZERO, get_hash(), GETARG, GETASTER, GETNUM, GETPOSARG, hash(), INT2FIX, INTEGER_PACK_2COMP, INTEGER_PACK_BIG_ENDIAN, isinf(), isnan, len, LONG2FIX, memcpy, NIL_P, NULL, NUM2INT, OBJ_TAINT, OBJ_TAINTED, PRIsVALUE, PRIuSIZE, PUSH, PUSH_, Qnil, Qundef, rb_absint_numwords(), rb_absint_singlebit_p(), rb_big2str(), rb_big_uminus(), rb_check_string_type(), rb_check_symbol_cstr(), rb_dbl2big(), rb_eArgError, rb_eKeyError, rb_enc_associate(), rb_enc_check(), rb_enc_codelen(), rb_enc_codepoint_len(), rb_enc_copy(), rb_enc_get(), rb_enc_isprint, rb_enc_mbclen(), rb_enc_mbcput, rb_enc_nth(), rb_enc_raise(), rb_enc_right_char_head, rb_enc_strlen(), rb_enc_toupper(), rb_Float(), RB_GC_GUARD, rb_hash_default_value(), rb_hash_lookup2(), rb_inspect(), rb_int2str(), rb_int_idiv(), rb_int_mul(), rb_int_plus(), rb_int_positive_pow(), rb_Integer(), rb_integer_pack(), RB_INTEGER_TYPE_P, rb_long2int, rb_obj_as_string(), rb_raise(), rb_rational_den(), rb_rational_num(), rb_str_buf_new(), rb_str_coderange_scan_restartable(), rb_str_new(), rb_str_new4, rb_str_resize(), rb_str_set_len(), rb_str_to_inum(), rb_sym2str, rb_sym_intern(), RB_TYPE_P, rb_warn(), result, RFLOAT_VALUE, RSTRING_END, RSTRING_LEN, RSTRING_PTR, RTEST, ruby_debug, ruby_digitmap, ruby_verbose, sign_bits(), SIGNED_VALUE, snprintf, StringValue, strlen(), sym, T_BIGNUM, T_FIXNUM, T_FLOAT, T_RATIONAL, T_STRING, term, TRUE, TYPE, val, and zero().
Referenced by date_strftime_with_tmx(), name_err_mesg_to_str(), rb_f_sprintf(), rb_str_format_m(), rb_strftime_with_timespec(), str_upto_each(), and uncaught_throw_to_s().
Definition at line 1453 of file sprintf.c.
References __SSTR, __SWR, BSD_vfprintf(), f, rb_str_capacity(), rb_str_modify(), rb_str_resize(), RBASIC, RBASIC_CLEAR_CLASS, RBASIC_SET_CLASS_RAW, RSTRING_END, RSTRING_PTR, ruby__sfvextra(), ruby__sfvwrite(), StringValue, and rb_printf_buffer_extra::value.
Referenced by dump_append(), err_vcatf(), init_env(), rb_parser_printf(), and rb_str_catf().
Definition at line 1434 of file sprintf.c.
References NULL, and rb_enc_vsprintf().
Referenced by ole_raise(), ossl_make_error(), parser_compile_error(), rb_fatal(), rb_name_error(), rb_name_error_str(), rb_raise(), and rb_sprintf().
|
static |
Definition at line 1331 of file sprintf.c.
References ECONV_INVALID_REPLACE, ECONV_UNDEF_REPLACE, if(), LITERAL, OBJ_INFECT, Qnil, QUOTE, rb_cFalseClass, rb_cInteger, rb_cNilClass, rb_cSymbol, rb_cTrueClass, rb_enc_associate(), rb_enc_compatible(), rb_enc_get(), rb_eRuntimeError, rb_inspect(), rb_obj_as_string(), rb_raise(), rb_str_conv_enc_opts(), RB_TYPE_P, RBASIC, result, RSTRING_GETMEM, StringValueCStr, and T_CLASS.
Referenced by rb_enc_vsprintf(), and rb_str_vcatf().
|
static |
Definition at line 1304 of file sprintf.c.
References buf, CHECK, __siov::iov_base, __siov::iov_len, len, MEMCPY, rb_eRuntimeError, rb_raise(), rb_str_set_len(), RBASIC, result, RSTRING_PTR, __suio::uio_iov, and __suio::uio_resid.
Referenced by rb_enc_vsprintf(), and rb_str_vcatf().
int ruby_snprintf | ( | char * | str, |
size_t | n, | ||
char const * | fmt, | ||
... | |||
) |
Definition at line 1284 of file sprintf.c.
References EOF, and ruby_vsnprintf().
int ruby_vsnprintf | ( | char * | str, |
size_t | n, | ||
const char * | fmt, | ||
va_list | ap | ||
) |
Definition at line 1266 of file sprintf.c.
References __SSTR, __SWR, BSD__sfvwrite(), BSD_vfprintf(), EOF, and f.
Referenced by ruby_snprintf().
|
static |
Definition at line 29 of file sprintf.c.
Referenced by rb_str_format().