diff options
author | Rupak Rokade | 2021-04-26 14:58:22 +0530 |
---|---|---|
committer | GitHub | 2021-04-26 14:58:22 +0530 |
commit | c6fd117ed4944b99d5974c77c8a82a2f564f0539 (patch) | |
tree | a29484d05688642cb61bb7ced21e601a3be969da /sci_gateway | |
parent | e43fd7fe8ac865bd26b2cd15f7574653870c775c (diff) | |
parent | 540c02f594fe49e47828a589115f282f95304b72 (diff) | |
download | fossee-scilab-octave-toolbox-c6fd117ed4944b99d5974c77c8a82a2f564f0539.tar.gz fossee-scilab-octave-toolbox-c6fd117ed4944b99d5974c77c8a82a2f564f0539.tar.bz2 fossee-scilab-octave-toolbox-c6fd117ed4944b99d5974c77c8a82a2f564f0539.zip |
Merge pull request #2 from ananmaysuri/master
Capturing the original octave error messages and returning them to scilab
Diffstat (limited to 'sci_gateway')
-rwxr-xr-x | sci_gateway/cpp/libscilab_octave.so | bin | 21536 -> 27400 bytes | |||
-rw-r--r-- | sci_gateway/cpp/sci_octave.cpp | 35 |
2 files changed, 25 insertions, 10 deletions
diff --git a/sci_gateway/cpp/libscilab_octave.so b/sci_gateway/cpp/libscilab_octave.so Binary files differindex 229a76c..e5c4f0f 100755 --- a/sci_gateway/cpp/libscilab_octave.so +++ b/sci_gateway/cpp/libscilab_octave.so diff --git a/sci_gateway/cpp/sci_octave.cpp b/sci_gateway/cpp/sci_octave.cpp index 2ba43b5..5f1f685 100644 --- a/sci_gateway/cpp/sci_octave.cpp +++ b/sci_gateway/cpp/sci_octave.cpp @@ -9,9 +9,11 @@ // Organization: FOSSEE, IIT Bombay // Email: toolbox@scilab.in +#include <iostream> #include <string> #include "wchar.h" #include <cstdlib> +#include <sstream> extern "C" { @@ -56,7 +58,7 @@ int sci_octave_fun(scilabEnv env, int nin, scilabVar* in, int nopt, scilabOpt* o char* c; double* n = NULL; int row = 0; - int col = 0; + int col = 0; double* in_real; double* in_img; @@ -147,13 +149,26 @@ int sci_octave_fun(scilabEnv env, int nin, scilabVar* in, int nopt, scilabOpt* o } } else - { - Scierror(999, _("%s: Wrong type of input argument %d.\n"), fname, i); - return STATUS_ERROR; - } + { + Scierror(999, _("%s: Wrong type of input argument %d.\n"), fname, i); + return STATUS_ERROR; + } } + + // Capturing Errors and warnings + std::stringstream buffer_err; + + // set our error buffer + std::cerr.rdbuf(buffer_err.rdbuf()); + + int status_fun = fun(argptr, funptr); - int status_fun = fun(argptr, funptr); + // grab error buffer contents + std::string err = buffer_err.str(); + + if(!err.empty() && status_fun==0) + sciprint("Warning from Octave\n%s", err.c_str()); + buffer_err.str(""); //printf("in scilab status_fun is: %d\n", status_fun); //printf("in scilab funcall.n_out_arguments is: %d\n", funcall.n_out_arguments); //printf("in scilab funcall.n_out_user is: %d\n", funcall.n_out_user); @@ -164,7 +179,7 @@ int sci_octave_fun(scilabEnv env, int nin, scilabVar* in, int nopt, scilabOpt* o //printf("in scilab ouput args are: %d\n", funcall.n_out_arguments); if(status_fun==1) { - Scierror(999, "\nOctave unable to process!\nCorrect usage:\n octave_fun(\"octave_function\",input1,input2,...)\n octave_fun(\"octave_function\",input1,input2,...,optional_input1,optional_input2,...)\n octave_fun(\"octave_function\",\"octave_package\",input1,input2,...)\n octave_fun(\"octave_function\",\"octave_package\",input1,input2,...,optional_input1,optional_input2,...)\n"); + Scierror(999,"Error from Octave\n%s", err.c_str()); return 1; } else if(funcall.n_out_user <= funcall.n_out_arguments) @@ -211,9 +226,9 @@ int sci_octave_fun(scilabEnv env, int nin, scilabVar* in, int nopt, scilabOpt* o } else { - Scierror(77, _("%s: Wrong number of output arguments: This function can return a maximum of %d output(s).\n"), fname, funcall.n_out_arguments); - return 1; - } + Scierror(77, _("%s: Wrong number of output arguments: This function can return a maximum of %d output(s).\n"), fname, funcall.n_out_arguments); + return 1; + } |