1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
/*
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) DIGITEO - 2009 - Allan CORNET
*
* This file must be used under the terms of the CeCILL.
* This source file is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at
* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
*
*/
/*--------------------------------------------------------------------------*/
#include "stack-c.h"
#include "localization.h"
#include "Scierror.h"
#include "BOOL.h"
#include "freeArrayOfString.h"
#include "MALLOC.h"
#include "getCommonPart.h"
/*--------------------------------------------------------------------------*/
int sci_getcommonpart(char *fname,unsigned long fname_len)
{
CheckRhs(1,1);
CheckLhs(1,1);
if (GetType(1) == sci_strings)
{
int m = 0, n = 0;
char **InputString = NULL;
char *Output = NULL;
GetRhsVar(1,MATRIX_OF_STRING_DATATYPE,&m,&n,&InputString);
if ( ( (m == 1) && (n !=1) ) || ( (m != 1) && (n ==1) ) )
{
Output = getCommonPart(InputString, m*n);
freeArrayOfString(InputString, m*n);
if (Output == NULL)
{
int l = 0;
m = 0, n = 0;
CreateVar(Rhs+1,STRING_DATATYPE, &m, &n, &l);
}
else
{
n = 1;
CreateVarFromPtr(Rhs+1,STRING_DATATYPE,(m=(int)strlen(Output), &m),&n, &Output);
if (Output) {FREE(Output);Output = NULL;}
}
LhsVar(1) = Rhs+1;
}
else
{
freeArrayOfString(InputString, m*n);
Scierror(999,_("%s: Wrong size for input argument %d.\n"),fname,1);
}
}
else
{
Scierror(999,_("%s: Wrong type for input arguments.\n"),fname);
}
return 0;
}
/*--------------------------------------------------------------------------*/
|