예제 #1
0
파일: fcgi.c 프로젝트: luongtran/po_tracker
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;
}
예제 #2
0
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;
}
예제 #3
0
파일: ruby.c 프로젝트: Netfart/rhodes
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;
}
예제 #4
0
파일: if_ruby.c 프로젝트: LemonBoy/vim
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);
    }
}
예제 #5
0
static VALUE global_spec_rb_lastline_get(VALUE self) {
  return rb_lastline_get();
}