Change version for removal of str2code & code2str 24/11124/3
Vincent COUVERT [Thu, 28 Mar 2013 09:06:33 +0000 (10:06 +0100)]
Change-Id: I89bc1a0498fde43ea5a60f1c794d69846ccf7177

scilab/modules/functions/help/en_US/code2str.xml
scilab/modules/functions/help/en_US/str2code.xml
scilab/modules/string/sci_gateway/c/sci_code2str.c
scilab/modules/string/sci_gateway/c/sci_str2code.c

index 75341ad..82f05b9 100644 (file)
@@ -67,7 +67,7 @@ str2code('Scilab')'
         <revhistory>
             <revision>
                 <revnumber>5.4.0</revnumber>
-                <revremark>This function will be removed in Scilab 5.4.1</revremark>
+                <revremark>This function will be removed in Scilab 6.0.0</revremark>
             </revision>
         </revhistory>
     </refsection>
index ca73875..a42b888 100644 (file)
@@ -67,7 +67,7 @@ code2str([-28 12 18 21 10 11])
         <revhistory>
             <revision>
                 <revnumber>5.4.0</revnumber>
-                <revremark>This function will be removed in Scilab 5.4.1</revremark>
+                <revremark>This function will be removed in Scilab 6.0.0</revremark>
             </revision>
         </revhistory>
     </refsection>
index b4b27de..79dfedc 100644 (file)
@@ -1,11 +1,11 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) INRIA - Cong WU
- * 
+ *
  * 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    
+ * are also available at
  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  *
  */
 #include "warningmode.h"
 #include "sciprint.h"
 /*--------------------------------------------------------------------------*/
-int sci_code2str(char *fname,unsigned long fname_len)
+int sci_code2str(char *fname, unsigned long fname_len)
 {
-       char **Output_Matrix = NULL;
-       int Row_Num = 0,Col_Num = 0;
-       int *Input_Matrix = NULL; /* Input matrix */
+    char **Output_Matrix = NULL;
+    int Row_Num = 0, Col_Num = 0;
+    int *Input_Matrix = NULL; /* Input matrix */
 
-       int numRow = 1;
-       int numCol = 0;
-       int outIndex = 0 ;
+    int numRow = 1;
+    int numCol = 0;
+    int outIndex = 0 ;
 
-       CheckRhs(1,1);
-       CheckLhs(1,1);
+    CheckRhs(1, 1);
+    CheckLhs(1, 1);
 
     if (strcmp(fname, "code2str") == 0)
     {
@@ -45,63 +45,66 @@ int sci_code2str(char *fname,unsigned long fname_len)
         {
             sciprint(_("%s: Feature %s is obsolete.\n"), _("Warning"), fname);
             sciprint(_("%s: Please use %s instead.\n"), _("Warning"), "ascii");
-            sciprint(_("%s: This feature will be permanently removed in Scilab %s\n\n"), _("Warning"), "5.4.1");
+            sciprint(_("%s: This feature will be permanently removed in Scilab %s\n\n"), _("Warning"), "6.0.0");
         }
     }
 
-       if (VarType(1) == sci_matrix)
-       {
-               int Stack_position = 0;
-               GetRhsVar(1,MATRIX_OF_INTEGER_DATATYPE,&Row_Num,&Col_Num,&Stack_position);
-               Input_Matrix=istk(Stack_position); /* Input*/
-       }
-       else
-       {
-               Scierror(999,_("%s: Wrong type for input argument #%d: Real matrix expected.\n"),fname,1);
-               return 0;
-       }
-
-       numCol   = Row_Num*Col_Num ;
-
-       /* Allocation output matrix */
-       Output_Matrix = (char**)MALLOC(sizeof(char*)); 
-
-       if (Output_Matrix == NULL)
-       {
-               Scierror(999,_("%s: No more memory.\n"),fname);
-               return 0;
-       }
-
-       if (numCol != 0) 
-       {
-               Output_Matrix[0]=(char*)MALLOC(sizeof(char*)*(numCol));
-       }
-       else Output_Matrix[0]=(char*)MALLOC(sizeof(char*));
-
-       if (Output_Matrix[0] == NULL)
-       {
-               FREE(Output_Matrix);
-               Output_Matrix = NULL;
-               Scierror(999,_("%s: No more memory.\n"),fname);
-               return 0;
-       }
-
-       /* code2str algorithm */
-
-       code2str(Output_Matrix,Input_Matrix,Row_Num*Col_Num);
-
-       /* put on scilab stack */
-       numRow   = 1 ; /*Output number row */
-       outIndex = 0 ;
-       CreateVar(Rhs+1,STRING_DATATYPE,&numRow,&numCol,&outIndex);
-       strncpy(cstk(outIndex), &Output_Matrix[0][0] ,numCol ) ;
+    if (VarType(1) == sci_matrix)
+    {
+        int Stack_position = 0;
+        GetRhsVar(1, MATRIX_OF_INTEGER_DATATYPE, &Row_Num, &Col_Num, &Stack_position);
+        Input_Matrix = istk(Stack_position); /* Input*/
+    }
+    else
+    {
+        Scierror(999, _("%s: Wrong type for input argument #%d: Real matrix expected.\n"), fname, 1);
+        return 0;
+    }
+
+    numCol   = Row_Num * Col_Num ;
+
+    /* Allocation output matrix */
+    Output_Matrix = (char**)MALLOC(sizeof(char*));
+
+    if (Output_Matrix == NULL)
+    {
+        Scierror(999, _("%s: No more memory.\n"), fname);
+        return 0;
+    }
+
+    if (numCol != 0)
+    {
+        Output_Matrix[0] = (char*)MALLOC(sizeof(char*) * (numCol));
+    }
+    else
+    {
+        Output_Matrix[0] = (char*)MALLOC(sizeof(char*));
+    }
+
+    if (Output_Matrix[0] == NULL)
+    {
+        FREE(Output_Matrix);
+        Output_Matrix = NULL;
+        Scierror(999, _("%s: No more memory.\n"), fname);
+        return 0;
+    }
+
+    /* code2str algorithm */
+
+    code2str(Output_Matrix, Input_Matrix, Row_Num * Col_Num);
+
+    /* put on scilab stack */
+    numRow   = 1 ; /*Output number row */
+    outIndex = 0 ;
+    CreateVar(Rhs + 1, STRING_DATATYPE, &numRow, &numCol, &outIndex);
+    strncpy(cstk(outIndex), &Output_Matrix[0][0] , numCol ) ;
 
     /* free pointers */
     freeArrayOfString(Output_Matrix, 1);
 
-       LhsVar(1) = Rhs+1 ;
-       PutLhsVar();
-       
-       return 0;
+    LhsVar(1) = Rhs + 1 ;
+    PutLhsVar();
+
+    return 0;
 }
-/*--------------------------------------------------------------------------*/ 
+/*--------------------------------------------------------------------------*/
index eecffe5..afcde5a 100644 (file)
 #include "warningmode.h"
 #include "sciprint.h"
 /*----------------------------------------------------------------------------*/
-int sci_str2code(char *fname,unsigned long fname_len)
+int sci_str2code(char *fname, unsigned long fname_len)
 {
-       CheckRhs(1,1);
-       CheckLhs(1,1);
+    CheckRhs(1, 1);
+    CheckLhs(1, 1);
 
     if (strcmp(fname, "str2code") == 0)
     {
@@ -36,71 +36,75 @@ int sci_str2code(char *fname,unsigned long fname_len)
         {
             sciprint(_("%s: Feature %s is obsolete.\n"), _("Warning"), fname);
             sciprint(_("%s: Please use %s instead.\n"), _("Warning"), "ascii");
-            sciprint(_("%s: This feature will be permanently removed in Scilab %s\n\n"), _("Warning"), "5.4.1");
+            sciprint(_("%s: This feature will be permanently removed in Scilab %s\n\n"), _("Warning"), "6.0.0");
         }
     }
 
-       if (VarType(1) == sci_strings)
-       {
-               char **Input_String = NULL;
-               int m1 = 0,n1 = 0;
-               int *Output_Matrix = NULL;
-               int nbOutput_Matrix = 0;
+    if (VarType(1) == sci_strings)
+    {
+        char **Input_String = NULL;
+        int m1 = 0, n1 = 0;
+        int *Output_Matrix = NULL;
+        int nbOutput_Matrix = 0;
+
+        GetRhsVar(1, MATRIX_OF_STRING_DATATYPE, &m1, &n1, &Input_String);
 
-               GetRhsVar(1,MATRIX_OF_STRING_DATATYPE,&m1,&n1,&Input_String);
+        if ( ( strcmp(Input_String[0], "") == 0 ) || (Input_String[0] == NULL) )
+        {
+            /* str2code('') returns [] */
+            int l = 0;
 
-               if ( ( strcmp(Input_String[0],"") == 0 ) || (Input_String[0] == NULL) )
-               {
-                       /* str2code('') returns [] */
-                       int l = 0;
+            freeArrayOfString(Input_String, m1 * n1);
 
-                       freeArrayOfString(Input_String,m1*n1);
+            m1 = 0;
+            n1 = 0;
+            CreateVar(Rhs + 1, MATRIX_OF_DOUBLE_DATATYPE, &m1, &n1, &l);
+            LhsVar(1) = Rhs + 1 ;
+            PutLhsVar();
 
-                       m1 = 0;
-                       n1 = 0;
-                       CreateVar(Rhs+1,MATRIX_OF_DOUBLE_DATATYPE,&m1,&n1,&l);
-                       LhsVar(1) = Rhs+1 ;
-                       PutLhsVar();
-                       
-                       return 0;
-               }
-               else
-               {
-                       if (strlen(Input_String[0])) nbOutput_Matrix = (int)strlen(Input_String[0]);
-                       Output_Matrix = (int*)MALLOC( sizeof(int) * nbOutput_Matrix );
-                       if (Output_Matrix)
-                       {
-                               int i = 0;
-                               int numRow   = 1 ;
-                               int outIndex = 0;
+            return 0;
+        }
+        else
+        {
+            if (strlen(Input_String[0]))
+            {
+                nbOutput_Matrix = (int)strlen(Input_String[0]);
+            }
+            Output_Matrix = (int*)MALLOC( sizeof(int) * nbOutput_Matrix );
+            if (Output_Matrix)
+            {
+                int i = 0;
+                int numRow   = 1 ;
+                int outIndex = 0;
 
-                               str2code(Output_Matrix,Input_String);
-                               freeArrayOfString(Input_String,m1*n1);
+                str2code(Output_Matrix, Input_String);
+                freeArrayOfString(Input_String, m1 * n1);
 
-                               /* put on scilab stack */
-                               CreateVar(Rhs+1,MATRIX_OF_DOUBLE_DATATYPE,&nbOutput_Matrix,&numRow,&outIndex);    /*Output*/
-                               for ( i = 0 ; i < nbOutput_Matrix ; i++ )
-                               {
-                                       stk(outIndex)[i] = (double)Output_Matrix[i] ;
-                               }
+                /* put on scilab stack */
+                CreateVar(Rhs + 1, MATRIX_OF_DOUBLE_DATATYPE, &nbOutput_Matrix, &numRow, &outIndex); /*Output*/
+                for ( i = 0 ; i < nbOutput_Matrix ; i++ )
+                {
+                    stk(outIndex)[i] = (double)Output_Matrix[i] ;
+                }
 
-                               /* free pointers */
-                               FREE(Output_Matrix); Output_Matrix=NULL;
+                /* free pointers */
+                FREE(Output_Matrix);
+                Output_Matrix = NULL;
 
-                LhsVar(1) = Rhs+1 ;
+                LhsVar(1) = Rhs + 1 ;
                 PutLhsVar();
-                       }
-                       else
-                       {
-                               freeArrayOfString(Input_String,m1*n1);
-                               Scierror(999,_("%s: No more memory.\n"),fname);
-                       }
-               }
-       }
-       else
-       {
-               Scierror(999,_("%s: Wrong type for input argument #%d: Matrix of strings expected.\n"),fname,1);
-       }
-       return 0;
+            }
+            else
+            {
+                freeArrayOfString(Input_String, m1 * n1);
+                Scierror(999, _("%s: No more memory.\n"), fname);
+            }
+        }
+    }
+    else
+    {
+        Scierror(999, _("%s: Wrong type for input argument #%d: Matrix of strings expected.\n"), fname, 1);
+    }
+    return 0;
 }
 /*----------------------------------------------------------------------------*/