Ejemplo n.º 1
0
static VALUE ruby_coroutine_body_require(const char* file)
{
    int error;
    VALUE result = rb_protect((VALUE (*)(VALUE))rb_require,
                              (VALUE)file, &error);

    if (error)
    {
        printf("rb_require('%s') failed with status=%d\n",
               file, error);

        VALUE exception = rb_gv_get("$!");
        if (RTEST(exception))
        {
            printf("... because an exception was raised:\n");
            fflush(stdout);

            VALUE inspect = rb_inspect(exception);
            rb_io_puts(1, &inspect, rb_stderr);

            VALUE backtrace = rb_funcall(
                exception, rb_intern("backtrace"), 0);
            rb_io_puts(1, &backtrace, rb_stderr);
        }
    }

    return result;
}
Ejemplo n.º 2
0
static rpmRC rpmrubyRunThreadFile(rpmruby ruby, const char * fn,
		const char **resultp)
{
    int error;
    VALUE result;
    rpmRC rc = RPMRC_FAIL;	/* assume failure */

    result = rb_protect((VALUE (*)(VALUE))rb_require, (VALUE)fn, &error);
    if (error) {
        fprintf(stderr, "rb_require('%s') failed with status=%d\n",
               fn, error);

        VALUE exception = rb_gv_get("$!");
        if (RTEST(exception)) {
            fprintf(stderr, "... because an exception was raised:\n");

            VALUE inspect = rb_inspect(exception);
            rb_io_puts(1, &inspect, rb_stderr);

            VALUE backtrace = rb_funcall(
                exception, rb_intern("backtrace"), 0);
            rb_io_puts(1, &backtrace, rb_stderr);
        }
    } else {
	/* XXX FIXME: check result */
	rc = RPMRC_OK;
    }

    return rc;
}
Ejemplo n.º 3
0
static VALUE gp_polinterpolate(VALUE self, VALUE sxa, VALUE sya, VALUE sx) {
  rb_io_puts(1, &sxa, rb_stdout); 
  rb_io_puts(1, &sya, rb_stdout); 
  rb_io_puts(1, &sx, rb_stdout); 
  GEN xa = geval(strtoGENstr(StringValueCStr(sxa)));
  GEN ya = geval(strtoGENstr(StringValueCStr(sya)));
  GEN x = geval(strtoGENstr(StringValueCStr(sx)));
  char* pol = GENtostr(polint(xa, ya, x, NULL));
  return rb_str_new2(pol);
}
Ejemplo n.º 4
0
static void
stacktrace_dumper(int signum)
{
    #define MAX_TRACES 1024
    static void *trace[MAX_TRACES];
    int n;
    VALUE backtrace_arr;

    backtrace_arr = rb_make_backtrace();
    fprintf(stderr,
            "-- Ruby level backtrace --------------------------------------\n");
    rb_io_puts(1, &backtrace_arr, rb_stderr);
    fprintf(stderr, "\n");

    fprintf(stderr,
            "-- C level backtrace -----------------------------------------\n");
#if defined(HAVE_BACKTRACE) && !defined(__APPLE__)
    n = backtrace(trace, MAX_TRACES);
    backtrace_symbols_fd(trace, n, STDERR_FILENO);
#elif defined(HAVE_BACKTRACE) && defined(__APPLE__)
    fprintf(stderr,
            "C level backtrace is unavailable due to the bug in the OSX's environment.\nSee r39301 and r39808 of CRuby for the details.\n");
#else
    fprintf(stderr,
            "C level backtrace is unavailable because backtrace(3) is unavailable.\n")
#endif
    exit(exitcode);
}
Ejemplo n.º 5
0
Archivo: error.c Proyecto: knugie/ruby
static VALUE
rb_warn_m(int argc, VALUE *argv, VALUE exc)
{
    if (!NIL_P(ruby_verbose) && argc > 0) {
	rb_io_puts(argc, argv, rb_stderr);
    }
    return Qnil;
}