From 1ba24c545c462a5394575a993d0dc3faddb3928c Mon Sep 17 00:00:00 2001 From: fenrir Date: Sat, 6 Aug 2016 00:20:29 +0900 Subject: [PATCH 1/2] Fix unwanted exit in nerror(); use rb_raise instead. --- ext/nrutil.h | 2 ++ ext/svd.c | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ext/nrutil.h b/ext/nrutil.h index 1896a47..0523758 100644 --- a/ext/nrutil.h +++ b/ext/nrutil.h @@ -88,6 +88,7 @@ float *vector(); /* function definition */ +#if 0 void nrerror(char error_text[]) /* Numerical Recipes standard error handler */ { @@ -96,6 +97,7 @@ void nrerror(char error_text[]) fprintf(stderr, "...now exiting to system...\n"); exit(1); } +#endif float *vector(long nl, long nh) /* allocate a float vector with subscript range v[nl..nr] */ diff --git a/ext/svd.c b/ext/svd.c index 8145e60..c72cebb 100644 --- a/ext/svd.c +++ b/ext/svd.c @@ -21,7 +21,6 @@ VALUE decompose(VALUE module, VALUE matrix_ruby, VALUE m_ruby, VALUE n_ruby) { /* precondition */ if((m*n) != RARRAY_LEN(matrix_ruby)) { rb_raise(rb_eRangeError, "Size of the array is not equal to m * n"); - return; } /* convert to u matrix */ @@ -64,3 +63,9 @@ void Init_svd() VALUE module = rb_define_module("SVD"); rb_define_module_function(module, "decompose", decompose, 3); } + +void nrerror(char error_text[]) + /* Numerical Recipes standard error handler */ +{ + rb_raise(rb_eRuntimeError, "Numerical Recipes run-time error...\n%s\n", error_text); +} From 6c22676f90c5678524bd34837322617e5457b6f2 Mon Sep 17 00:00:00 2001 From: fenrir Date: Sat, 6 Aug 2016 00:28:34 +0900 Subject: [PATCH 2/2] Add raise error for (m