summaryrefslogtreecommitdiff
path: root/sci_gateway/cpp
diff options
context:
space:
mode:
authorrupak2019-09-06 13:41:46 +0530
committerrupak2019-09-06 13:41:46 +0530
commit74a2b6c725d09877fbc33103454932c4c005a016 (patch)
tree7bffe19d1446a871361b0bac82eabe34467386f4 /sci_gateway/cpp
parent08e0c7b9e0b0bdaaae8365a905af0198550a7c61 (diff)
downloadfossee-scilab-octave-toolbox-74a2b6c725d09877fbc33103454932c4c005a016.tar.gz
fossee-scilab-octave-toolbox-74a2b6c725d09877fbc33103454932c4c005a016.tar.bz2
fossee-scilab-octave-toolbox-74a2b6c725d09877fbc33103454932c4c005a016.zip
scilab now checks for incorrect input arguments
Diffstat (limited to 'sci_gateway/cpp')
-rwxr-xr-xsci_gateway/cpp/libscilab_toolbox.sobin17368 -> 17600 bytes
-rw-r--r--sci_gateway/cpp/sci_matrix.cpp53
2 files changed, 41 insertions, 12 deletions
diff --git a/sci_gateway/cpp/libscilab_toolbox.so b/sci_gateway/cpp/libscilab_toolbox.so
index 5e204b2..d336448 100755
--- a/sci_gateway/cpp/libscilab_toolbox.so
+++ b/sci_gateway/cpp/libscilab_toolbox.so
Binary files differ
diff --git a/sci_gateway/cpp/sci_matrix.cpp b/sci_gateway/cpp/sci_matrix.cpp
index c2da80c..1edbf16 100644
--- a/sci_gateway/cpp/sci_matrix.cpp
+++ b/sci_gateway/cpp/sci_matrix.cpp
@@ -21,6 +21,22 @@ static const char fname[] = "octave_fun";
int sci_octave_fun(scilabEnv env, int nin, scilabVar* in, int nopt, scilabOpt* opt, int nout, scilabVar* out)
{
+ if (nin < 3)
+ {
+ Scierror(999, _("%s: Wrong number of input arguments: %d expected.\n"), fname, 3);
+ return STATUS_ERROR;
+ }
+
+int typ=0;
+ for(int i=1;i<nin+1;i++)
+ {
+ typ = scilab_getType(env, in[i-1]);
+ printf("Type of input %d is: %d\n",i,typ);
+ }
+printf("%s\n","1 - sci_matrix: a matrix of doubles");
+printf("%s\n","10 - sci_strings: a matrix of strings");
+printf("%s\n", "=================================");
+
/*
printf("%d\n", nin);
int row = 0;
@@ -38,7 +54,7 @@ int sci_octave_fun(scilabEnv env, int nin, scilabVar* in, int nopt, scilabOpt* o
int size = 0;
size = scilab_getDim2d(env, in[0], &row, &col);
scilab_getDoubleArray(env, in[0], &n);
- double ar[(int)n[0]];
+ double ar[(int)n[0]];//output size can be defined here
// if((int)n[0]!=NULL)
// if(in[i]!=NULL)
@@ -49,24 +65,37 @@ int sci_octave_fun(scilabEnv env, int nin, scilabVar* in, int nopt, scilabOpt* o
wchar_t* in1 = 0;
char str[20];
+ if (scilab_isString(env, in[1]) == 0)
+ {
+ Scierror(999, _("%s: Wrong type for input argument #%d: A String expected.\n"), fname, 2);
+ return STATUS_ERROR;
+ }
+ else
+ {
+ scilab_getString(env, in[1], &in1);
+ //printf("%S\n", in1);
- scilab_getString(env, in[1], &in1);
- //printf("%S\n", in1);
-
- wcstombs(str, in1, sizeof(str));
- //printf("%s\n", str);
-
+ wcstombs(str, in1, sizeof(str));
+ //printf("%s\n", str);
+ }
////////////////Third Input/////////////////////
wchar_t* in4 = 0;
char str2[20];
- scilab_getString(env, in[2], &in4);
- //printf("%S\n", in1);
-
- wcstombs(str2, in4, sizeof(str2));
- //printf("%s\n", str);
+ if (scilab_isString(env, in[2]) == 0 || nin < 3)
+ {
+ Scierror(999, _("%s: Wrong type for input argument #%d: A String expected.\n"), fname, 3);
+ return STATUS_ERROR;
+ }
+ else
+ {
+ scilab_getString(env, in[2], &in4);
+ //printf("%S\n", in1);
+ wcstombs(str2, in4, sizeof(str2));
+ //printf("%s\n", str);
+ }
//if (nin != 0)