scilab_sprintf corrected and fscanfMat/fprintfMat plugged. 14/12114/3
Cedric Delamarre [Tue, 23 Jul 2013 09:47:31 +0000 (11:47 +0200)]
test_run("fileio","fprintfMat.encoding",["no_check_error_output" ]);
test_run("fileio","fscanfMat",["no_check_error_output" ]);

Change-Id: I6071a1cd084cefd419f5050fc19fb330183913fd

scilab/modules/fileio/includes/mopen.h
scilab/modules/fileio/sci_gateway/cpp/fileio_gw.cpp
scilab/modules/fileio/src/c/fscanfMat.c
scilab/modules/fileio/src/cpp/mopen.cpp
scilab/modules/output_stream/src/cpp/scilab_sprintf.cpp
scilab/modules/scicos_blocks/src/c/fromws_c.c
scilab/modules/scicos_blocks/src/c/tows_c.c

index 045e704..0545fbb 100644 (file)
@@ -37,7 +37,6 @@ typedef enum
     MOPEN_INVALID_STATUS = 5
 } mopenError;
 
-FILEIO_IMPEXP void C2F(mopen)(int *fd, char *file, char *status, int *f_swap, double *res, int *error);
 FILEIO_IMPEXP int mopen(wchar_t* _pstFilename, wchar_t* _pstMode, int _iSwap, int* _piID);
 
 #endif  /* __MOPEN_H__ */
index a9a3bd9..9858dde 100644 (file)
@@ -69,5 +69,7 @@ int FileioModule::Load()
     symbol::Context::getInstance()->addFunction(Function::createFunction(L"mfscanf", &sci_mfscanf, MODULE_NAME));
     symbol::Context::getInstance()->addFunction(Function::createFunction(L"msscanf", &sci_msscanf, MODULE_NAME));
     symbol::Context::getInstance()->addFunction(Function::createFunction(L"getdrives", &sci_getdrives, MODULE_NAME));
+    symbol::Context::getInstance()->addFunction(Function::createFunction(L"fprintfMat", &sci_fprintfMat, MODULE_NAME));
+    symbol::Context::getInstance()->addFunction(Function::createFunction(L"fscanfMat", &sci_fscanfMat, MODULE_NAME));
     return 1;
 }
index 9fd602f..4e4b6a9 100644 (file)
@@ -36,9 +36,9 @@
 #define NegInfString "-Inf"
 /*--------------------------------------------------------------------------*/
 #if _MSC_VER
-#define READ_ONLY_TEXT_MODE "rt"
+#define READ_ONLY_TEXT_MODE L"rt"
 #else
-#define READ_ONLY_TEXT_MODE "r"
+#define READ_ONLY_TEXT_MODE L"r"
 #endif
 /*--------------------------------------------------------------------------*/
 #define NB_FORMAT_SUPPORTED 7
@@ -75,7 +75,6 @@ fscanfMatResult *fscanfMat(char *filename, char *format, char *separator)
     int f_swap = 0;
     double res = 0.0;
     int errMOPEN = MOPEN_INVALID_STATUS;
-    double dErrClose = 0.;
     int errMGETL = MGETL_ERROR;
     int i = 0;
     int nbLinesTextDetected = 0;
@@ -88,6 +87,7 @@ fscanfMatResult *fscanfMat(char *filename, char *format, char *separator)
     char **lines = NULL;
     int nblines = 0;
     double *dValues = NULL;
+       wchar_t* filenameW = NULL;
 
     if ((filename == NULL) || (format == NULL) || (separator == NULL))
     {
@@ -109,7 +109,9 @@ fscanfMatResult *fscanfMat(char *filename, char *format, char *separator)
         return resultFscanfMat;
     }
 
-    C2F(mopen)(&fd, filename, READ_ONLY_TEXT_MODE, &f_swap, &res, &errMOPEN);
+    filenameW = to_wide_string(filename);
+    errMOPEN = mopen(filenameW, READ_ONLY_TEXT_MODE, f_swap, &fd);
+    FREE(filenameW);
     if (errMOPEN != MOPEN_NO_ERROR)
     {
         resultFscanfMat = (fscanfMatResult*)(MALLOC(sizeof(fscanfMatResult)));
@@ -135,7 +137,7 @@ fscanfMatResult *fscanfMat(char *filename, char *format, char *separator)
 
     freeArrayOfWideString(pwsLines, nblines);
 
-    C2F(mclose)(&fd, &dErrClose);
+    mclose(fd);
     if (errMGETL != MGETL_NO_ERROR)
     {
         resultFscanfMat = (fscanfMatResult*)(MALLOC(sizeof(fscanfMatResult)));
index ce07679..f528475 100644 (file)
@@ -84,9 +84,5 @@ int mopen(wchar_t* _pstFilename, wchar_t* _pstMode, int _iSwap, int* _piID)
     *_piID = FileManager::addFile(pFile);
     return MOPEN_NO_ERROR;
 }
-
-void C2F(mopen)(int *fd, char *file, char *status, int *f_swap, double *res, int *error)
-{
-}
 /*--------------------------------------------------------------------------*/
 
index 8de7f5c..25d1a0a 100644 (file)
@@ -205,10 +205,16 @@ wchar_t** scilab_sprintf(wchar_t* _pwstName, wchar_t* _pwstInput, typed_list &in
         pwstFirstOutput = NULL;
 
         int iLoop = 1;
+        int iFirstArg = 1;
+        if (wcscmp(_pwstName, L"mfprintf") == 0)
+        {
+            iFirstArg = 2;
+        }
+
         if (in.size() > 1)
         {
-            iLoop = in[1]->getAs<GenericType>()->getRows();
-            for (int i = 2 ; i < in.size() ; i++)
+            iLoop = in[iFirstArg]->getAs<GenericType>()->getRows();
+            for (int i = iFirstArg + 1 ; i < in.size() ; i++)
             {
                 iLoop = Min(iLoop, in[i]->getAs<GenericType>()->getRows());
             }
index 0109624..6a08217 100644 (file)
@@ -86,6 +86,7 @@ typedef struct
 /*--------------------------------------------------------------------------*/
 SCICOS_BLOCKS_IMPEXP void fromws_c(scicos_block *block, int flag)
 {
+#if 0
     double t = 0., y1 = 0., y2 = 0., t1 = 0., t2 = 0., r = 0.;
     double *spline = NULL, *A_d = NULL, *A_sd = NULL, *qdy = NULL;
     /* double  a,b,c,*y;*/
@@ -1483,6 +1484,7 @@ SCICOS_BLOCKS_IMPEXP void fromws_c(scicos_block *block, int flag)
         fromws_c(block, 4);
     }
     /*************************************************************************/
+#endif
 }
 /*--------------------------------------------------------------------------*/
 static int Ishm(int *fd, int *Ytype, int *nPoints, int *my, int *ny, int *YsubType)
index 7527969..0974355 100644 (file)
@@ -104,6 +104,7 @@ SCICOS_BLOCKS_IMPEXP void tows_c(scicos_block *block, int flag)
 * Author A.Layec - initial rev. 18/09/07
 */
 {
+#if 0
     /* for mopen */
     int fd;
     char *status;
@@ -1781,5 +1782,6 @@ SCICOS_BLOCKS_IMPEXP void tows_c(scicos_block *block, int flag)
             ptr->loop++;
         }
     }
+#endif
 }
 /*--------------------------------------------------------------------------*/