static VALUE fcgi_stream_print(int argc, VALUE *argv, VALUE out) { int i; VALUE line; /* if no argument given, print `$_' */ if (argc == 0) { argc = 1; line = rb_lastline_get(); argv = &line; } for (i=0; i<argc; i++) { if (!NIL_P(rb_output_fs) && i>0) { fcgi_stream_write(out, rb_output_fs); } switch (TYPE(argv[i])) { case T_NIL: fcgi_stream_write(out, rb_str_new2("nil")); break; default: fcgi_stream_write(out, argv[i]); break; } } if (!NIL_P(rb_output_rs)) { fcgi_stream_write(out, rb_output_rs); } return Qnil; }
static VALUE rg_print(int argc, VALUE *argv, VALUE out) { int i; VALUE line; VALUE output_field_separator; /* if no argument given, print `$_' */ if (argc == 0) { argc = 1; line = rb_lastline_get(); argv = &line; } output_field_separator = rb_gv_get("$,"); for (i=0; i<argc; i++) { if (!NIL_P(output_field_separator) && i>0) { rg_write(out, output_field_separator); } switch (TYPE(argv[i])) { case T_NIL: rg_write(out, rb_str_new2("nil")); break; default: rg_write(out, argv[i]); break; } } if (!NIL_P(output_field_separator)) { rg_write(out, output_field_separator); } return Qnil; }
static VALUE uscore_get() { VALUE line; line = rb_lastline_get(); if (TYPE(line) != T_STRING) { rb_raise(rb_eTypeError, "$_ value need to be String (%s given)", NIL_P(line) ? "nil" : rb_obj_classname(line)); } return line; }
void ex_rubydo(exarg_T *eap) { int state; linenr_T i; if (ensure_ruby_initialized()) { if (u_save(eap->line1 - 1, eap->line2 + 1) != OK) return; for (i = eap->line1; i <= eap->line2; i++) { VALUE line; line = vim_str2rb_enc_str((char *)ml_get(i)); rb_lastline_set(line); eval_enc_string_protect((char *) eap->arg, &state); if (state) { error_print(state); break; } line = rb_lastline_get(); if (!NIL_P(line)) { if (TYPE(line) != T_STRING) { EMSG(_("E265: $_ must be an instance of String")); return; } ml_replace(i, (char_u *) StringValuePtr(line), 1); changed(); #ifdef SYNTAX_HL syn_changed(i); /* recompute syntax hl. for this line */ #endif } } check_cursor(); update_curbuf(NOT_VALID); } }
static VALUE global_spec_rb_lastline_get(VALUE self) { return rb_lastline_get(); }