write function fixed 73/16773/5
Cedric Delamarre [Fri, 3 Jul 2015 08:46:39 +0000 (10:46 +0200)]
* test updated about Windows/Linux diff
* function fortran fixed about buffer displayed
* file opened must be closed when error occured

test_run io write

Change-Id: I83390fb680ba8b45eff1efdcfcd67ff38775545c

17 files changed:
scilab/modules/core/src/fortran/write_inter.f
scilab/modules/io/Makefile.am
scilab/modules/io/Makefile.in
scilab/modules/io/sci_gateway/cpp/sci_read.cpp
scilab/modules/io/sci_gateway/cpp/sci_write.cpp
scilab/modules/io/src/cpp/io_gw.vcxproj
scilab/modules/io/src/cpp/io_gw.vcxproj.filters
scilab/modules/io/src/cpp/readwrite.cpp [new file with mode: 0644]
scilab/modules/io/src/cpp/readwrite.hxx [new file with mode: 0644]
scilab/modules/io/tests/unit_tests/save_double_ref_Linux [new file with mode: 0644]
scilab/modules/io/tests/unit_tests/save_double_ref_windows [new file with mode: 0644]
scilab/modules/io/tests/unit_tests/save_int_ref_Linux [new file with mode: 0644]
scilab/modules/io/tests/unit_tests/save_int_ref_windows [new file with mode: 0644]
scilab/modules/io/tests/unit_tests/write.dia.ref [deleted file]
scilab/modules/io/tests/unit_tests/write.tst
scilab/modules/io/tests/unit_tests/write.unix.dia.ref [new file with mode: 0644]
scilab/modules/io/tests/unit_tests/write.win.dia.ref [new file with mode: 0644]

index 58e36a6..d47937e 100644 (file)
@@ -1,11 +1,11 @@
 c Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 c Copyright (C) INRIA
 c Copyright (C) ENPC
-c 
+c
 c This file must be used under the terms of the CeCILL.
 c This source file is licensed as described in the file COPYING, which
 c you should have received as part of this distribution.  The terms
-c are also available at    
+c are also available at
 c http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
 
       subroutine writedouble(form, dat, m, n, ierr)
@@ -16,7 +16,7 @@ c     &       (stk(li+j*m),j=0,n-1)
       double precision dat(*)
       integer m,n,ierr
       character form*(*)
-      
+
       !write (*, '(f)') dat(1)
       !write (*, '(f)') dat(2)
       do 65 i=1,m
@@ -24,15 +24,15 @@ c     &       (stk(li+j*m),j=0,n-1)
           lb1=lch
  66       lb1=lb1-1
           if(buf(lb1:lb1).eq.' ') goto 66
-      
+
           io = 0
           call basout(io, 6, buf(1:lb1))
- 65   continue      
+ 65   continue
       return
-      
+
 20    ierr = 2
       return
-      
+
       end
 
       subroutine writeint(form, dat, m, n, ierr)
@@ -43,7 +43,7 @@ c     &       (stk(li+j*m),j=0,n-1)
       integer dat(*)
       integer m,n,ierr
       character form*(*)
-      
+
       !write (*, '(f)') dat(1)
       !write (*, '(f)') dat(2)
       do 67 i=1,m
@@ -51,16 +51,16 @@ c     &       (stk(li+j*m),j=0,n-1)
           lb1=lch
  68       lb1=lb1-1
           if(buf(lb1:lb1).eq.' ') goto 68
-      
+
           io = 0
           call basout(io, 6, buf(1:lb1))
- 67   continue      
+ 67   continue
       return
-      
+
 20    ierr = 2
       return
-      
-      end      
+
+      end
 
 
       subroutine writestring(form, dat, ierr)
@@ -71,43 +71,43 @@ c     &       (stk(li+j*m),j=0,n-1)
       character dat*(*)
       integer ierr
 
-      
+
       write(buf,form,err=20) dat
       lb1=lch
  69   lb1=lb1-1
       if(buf(lb1:lb1).eq.' ') goto 69
-      
+
       call basout(io, 6, buf(1:lb1))
       return
-      
+
 20    ierr = 2
       return
-      
+
       end
 
       subroutine writestringfile(ID, form, dat, ierr)
-      
+
       parameter (lch=4096)
       character buf*(lch)
       integer ID,ierr
       character form*(*)
       character dat*(*)
-      
+
       do 99 i=1,len(dat),lch
           if(len(dat) < (i+lch-1)) then
               write(ID,form,err=20) dat(i:len(dat))
-          else          
+          else
               write(ID,form,err=20) dat(i:(i+lch-1))
           end if
-          
+
 99    continue
       return
-      
+
 20    ierr = 2
       return
-      
-      end  
-      
+
+      end
+
       subroutine writedoublefile(ID, form, dat,  m, n, ierr)
 
       parameter (lch=4096)
@@ -115,17 +115,17 @@ c     &       (stk(li+j*m),j=0,n-1)
       double precision dat(*)
       integer m,n,ierr
       character form*(*)
-      
-      
+
+
       do 71 i=1,m
           write(ID,form,err=20) (dat(j*m+i),j=0, n-1)
-      
- 71   continue      
+
+ 71   continue
       return
-      
+
 20    ierr = 2
       return
-      
+
       end
 
       subroutine writeintfile(ID, form, dat, m, n, ierr)
@@ -137,14 +137,14 @@ c     &       (stk(li+j*m),j=0,n-1)
 
       do 72 i=1,m
           write(ID,form,err=20) (dat(j*m+i),j=0, n-1)
-      
- 72   continue      
+
+ 72   continue
       return
-      
+
 20    ierr = 2
       return
-      
-      end 
+
+      end
 
       subroutine writedoubleszsc(form, dat, szsc, m, n, ierr)
 
@@ -154,30 +154,30 @@ c     &       (stk(li+j*m),j=0,n-1)
       double precision dat(*)
       integer m,n,szsc,ierr
       character form*(*)
-      
+
       do 73 i=1,m
           write(buf,form,err=20) (dat(j*m+i),j=0, n-1)
           lb1=lch
  74       lb1=lb1-1
           if(buf(lb1:lb1).eq.' ') goto 74
-      
+
       do 75 j=1,lb1,szsc
           if(lb1 < (j+szsr-1)) then
               write(buf2,*) buf(j:lb1)
-              
-          else          
+
+          else
               write(buf2,*) buf(j:(j+szsc-1))
           end if
-          
+
         io = 0
-        call basout(io, 6, buf2)
- 75   continue   
- 73   continue      
+        call basout(io, 6, buf2(1:(j+szsc-1)))
+ 75   continue
+ 73   continue
       return
-      
+
 20    ierr = 2
       return
-      
+
       end
 
       subroutine writedoubleszscfile(ID, dat, szsc,  m, n,ierr)
@@ -186,15 +186,15 @@ c     &       (stk(li+j*m),j=0,n-1)
       character buf*(lch)
       double precision dat(*)
       integer m,n,szsc,ierr
-      
+
       do 76 i=1,m
           write(ID,*,err=20) (dat(j*m+i),j=0, n-1)
- 76   continue  
+ 76   continue
       return
-      
+
 20    ierr = 2
       return
-      
+
       end
 
       subroutine writeintszsc(form, dat, szsc, m, n, ierr)
@@ -205,30 +205,30 @@ c     &       (stk(li+j*m),j=0,n-1)
       integer*4 dat(*)
       integer*4 m,n,szsc,ierr
       character form*(*)
-      
+
       do 79 i=1,m
           write(buf,form,err=20) (dat(j*m+i),j=0, n-1)
           lb1=lch
  80       lb1=lb1-1
           if(buf(lb1:lb1).eq.' ') goto 80
-      
+
       do 81 j=1,lb1,szsc
           if(lb1 < (j+szsr-1)) then
               write(buf2,*) buf(j:lb1)
-              
-          else          
+
+          else
               write(buf2,*) buf(j:(j+szsc-1))
           end if
-          
+
         io = 0
-        call basout(io, 6, buf2)
- 81   continue   
- 79   continue      
+        call basout(io, 6, buf2(1:(j+szsc-1)))
+ 81   continue
+ 79   continue
       return
-      
+
 20    ierr = 2
       return
-      
+
       end
 
       subroutine writeintszscfile(ID, form, dat, szsc,  m, n, ierr)
@@ -238,26 +238,26 @@ c     &       (stk(li+j*m),j=0,n-1)
       integer dat(*)
       integer m,n,szsc,ierr
       character form*(*)
-      
+
       do 82 i=1,m
           write(buf,form,err=20) (dat(j*m+i),j=0, n-1)
           lb1=lch
  83       lb1=lb1-1
           if(buf(lb1:lb1).eq.' ') goto 83
-      
+
       do 84 j=1,lb1,szsc
           if(lb1 < (j+szsc-1)) then
               write(ID,*) buf(j:lb1)
-              
-          else          
+
+          else
               write(ID,*) buf(j:(j+szsc-1))
           end if
 
- 84   continue   
- 82   continue  
+ 84   continue
+ 82   continue
       return
-      
+
 20    ierr = 2
       return
-      
+
       end
index e7a4117..04a672e 100644 (file)
@@ -13,7 +13,8 @@ IO_C_SOURCES = \
 
 IO_CPP_SOURCES = \
     src/cpp/io_gw.cpp \
-    src/cpp/loadlib.cpp
+    src/cpp/loadlib.cpp \
+    src/cpp/readwrite.cpp
 
 GATEWAY_C_SOURCES = \
     sci_gateway/c/sci_read4b.c \
index a294cb1..e27b583 100644 (file)
@@ -170,7 +170,8 @@ am__objects_1 = src/c/libsciio_algo_la-getpidc.lo \
        src/c/libsciio_algo_la-getenvc.lo \
        src/c/libsciio_algo_la-v2cuniterror.lo
 am__objects_2 = src/cpp/libsciio_algo_la-io_gw.lo \
-       src/cpp/libsciio_algo_la-loadlib.lo
+       src/cpp/libsciio_algo_la-loadlib.lo \
+       src/cpp/libsciio_algo_la-readwrite.lo
 am_libsciio_algo_la_OBJECTS = $(am__objects_1) $(am__objects_2)
 libsciio_algo_la_OBJECTS = $(am_libsciio_algo_la_OBJECTS)
 AM_V_lt = $(am__v_lt_@AM_V@)
@@ -576,7 +577,8 @@ IO_C_SOURCES = \
 
 IO_CPP_SOURCES = \
     src/cpp/io_gw.cpp \
-    src/cpp/loadlib.cpp
+    src/cpp/loadlib.cpp \
+    src/cpp/readwrite.cpp
 
 GATEWAY_C_SOURCES = \
     sci_gateway/c/sci_read4b.c \
@@ -836,6 +838,8 @@ src/cpp/libsciio_algo_la-io_gw.lo: src/cpp/$(am__dirstamp) \
        src/cpp/$(DEPDIR)/$(am__dirstamp)
 src/cpp/libsciio_algo_la-loadlib.lo: src/cpp/$(am__dirstamp) \
        src/cpp/$(DEPDIR)/$(am__dirstamp)
+src/cpp/libsciio_algo_la-readwrite.lo: src/cpp/$(am__dirstamp) \
+       src/cpp/$(DEPDIR)/$(am__dirstamp)
 
 libsciio-algo.la: $(libsciio_algo_la_OBJECTS) $(libsciio_algo_la_DEPENDENCIES) $(EXTRA_libsciio_algo_la_DEPENDENCIES) 
        $(AM_V_CXXLD)$(CXXLINK) $(am_libsciio_algo_la_rpath) $(libsciio_algo_la_OBJECTS) $(libsciio_algo_la_LIBADD) $(LIBS)
@@ -944,6 +948,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libsciio_algo_la-v2cuniterror.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libsciio_algo_la-io_gw.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libsciio_algo_la-loadlib.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libsciio_algo_la-readwrite.Plo@am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@   $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@@ -1112,6 +1117,13 @@ src/cpp/libsciio_algo_la-loadlib.lo: src/cpp/loadlib.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libsciio_algo_la-loadlib.lo `test -f 'src/cpp/loadlib.cpp' || echo '$(srcdir)/'`src/cpp/loadlib.cpp
 
+src/cpp/libsciio_algo_la-readwrite.lo: src/cpp/readwrite.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libsciio_algo_la-readwrite.lo -MD -MP -MF src/cpp/$(DEPDIR)/libsciio_algo_la-readwrite.Tpo -c -o src/cpp/libsciio_algo_la-readwrite.lo `test -f 'src/cpp/readwrite.cpp' || echo '$(srcdir)/'`src/cpp/readwrite.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libsciio_algo_la-readwrite.Tpo src/cpp/$(DEPDIR)/libsciio_algo_la-readwrite.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/readwrite.cpp' object='src/cpp/libsciio_algo_la-readwrite.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libsciio_algo_la-readwrite.lo `test -f 'src/cpp/readwrite.cpp' || echo '$(srcdir)/'`src/cpp/readwrite.cpp
+
 sci_gateway/cpp/libsciio_la-sci_genlib.lo: sci_gateway/cpp/sci_genlib.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sci_gateway/cpp/libsciio_la-sci_genlib.lo -MD -MP -MF sci_gateway/cpp/$(DEPDIR)/libsciio_la-sci_genlib.Tpo -c -o sci_gateway/cpp/libsciio_la-sci_genlib.lo `test -f 'sci_gateway/cpp/sci_genlib.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_genlib.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) sci_gateway/cpp/$(DEPDIR)/libsciio_la-sci_genlib.Tpo sci_gateway/cpp/$(DEPDIR)/libsciio_la-sci_genlib.Plo
index ea73aa5..91a8b65 100644 (file)
@@ -18,7 +18,7 @@
 #include "double.hxx"
 #include "int.hxx"
 #include "filemanager.hxx"
-
+#include "readwrite.hxx"
 
 extern "C"
 {
@@ -43,9 +43,6 @@ extern "C"
 
 using namespace types;
 
-InternalType::ScilabType checkformatread(const char* format);
-void closeFile(types::InternalType* _pIT, int _iID);
-
 template<typename T>
 bool is_of_type(const std::string & Str)
 {
@@ -145,7 +142,7 @@ Function::ReturnValue sci_read(typed_list &in, int _iRetCount, typed_list &out)
         //checkformat
         pstFormat = wide_string_to_UTF8(pSFormat->get(0));
 
-        itTypeOfData = checkformatread(pstFormat);
+        itTypeOfData = checkformat(pstFormat);
         if (itTypeOfData == InternalType::ScilabNull)
         {
             closeFile(in[0], iID);
@@ -444,8 +441,6 @@ Function::ReturnValue sci_read(typed_list &in, int _iRetCount, typed_list &out)
                                 pS->resize(iRows, iCols);
                                 pS->set((iRows - 1), (iCols - 1), pCt);
                             }
-                            FREE(pCt);
-
                         }
 
                         if (error == 0)
@@ -655,82 +650,3 @@ Function::ReturnValue sci_read(typed_list &in, int _iRetCount, typed_list &out)
 
     return Function::OK;
 }
-
-InternalType::ScilabType checkformatread(const char* format)
-{
-    const char type1[] =
-    {
-        'i', 'f', 'e',
-        'd', 'g', 'l',
-        'a', 'I', 'F',
-        'E', 'D', 'G',
-        'L', 'A'
-    };
-    const InternalType::ScilabType type2[] =
-    {
-        InternalType::ScilabInt32, InternalType::ScilabDouble, InternalType::ScilabDouble,
-        InternalType::ScilabDouble, InternalType::ScilabDouble, InternalType::ScilabBool,
-        InternalType::ScilabString, InternalType::ScilabInt32, InternalType::ScilabDouble,
-        InternalType::ScilabDouble, InternalType::ScilabDouble, InternalType::ScilabDouble,
-        InternalType::ScilabBool, InternalType::ScilabString
-    };
-
-    int size = (int)strlen(format);
-    bool isString = false;
-    InternalType::ScilabType previousType = InternalType::ScilabNull;
-
-    if (size < 2 || format[0] != '(' || format[size - 1] != ')')
-    {
-        return InternalType::ScilabNull;
-    }
-
-    for (int i = 1; i < size - 1; ++i)
-    {
-        char c = format[i];
-
-        if (c == '\'')
-        {
-            isString = !isString;
-        }
-
-        //while we are in string continue
-        if (isString)
-        {
-            continue;
-        }
-
-        for (int j = 0; j < sizeof(type1); j++)
-        {
-            if (c == type1[j])
-            {
-                if (previousType == InternalType::ScilabNull)
-                {
-                    previousType = type2[j];
-                }
-
-                //must have same format for all values
-                if (type2[j] != previousType)
-                {
-                    return InternalType::ScilabNull;
-                }
-
-                break;
-            }
-        }
-    }
-
-    return previousType;
-}
-
-void closeFile(types::InternalType* _pIT, int _iID)
-{
-    if (_pIT->isString())
-    {
-        int piMode[2] = { 0, 0 };
-        String* pSPath = _pIT->getAs<String>();
-        char* pstFilename = wide_string_to_UTF8(pSPath->get(0));
-        int  close = -_iID;
-        int iErr = C2F(clunit)(&close, pstFilename, piMode, (int)strlen(pstFilename));
-        FREE(pstFilename);
-    }
-}
index def9372..99c38b3 100644 (file)
@@ -18,7 +18,7 @@
 #include "double.hxx"
 #include "int.hxx"
 #include "filemanager.hxx"
-
+#include "readwrite.hxx"
 
 extern "C"
 {
@@ -43,9 +43,6 @@ extern "C"
 
 }
 
-int checkformat(char* format);
-
-
 using namespace types;
 
 /*--------------------------------------------------------------------------*/
@@ -81,6 +78,7 @@ Function::ReturnValue sci_write(typed_list &in, int _iRetCount, typed_list &out)
 
         if (iErr == 240)
         {
+            closeFile(in[0], iID);
             Scierror(999, _("File \"%s\" already exists or directory write access denied.\n"), pstFilename);
             FREE(pstFilename);
             return Function::Error;
@@ -129,12 +127,12 @@ Function::ReturnValue sci_write(typed_list &in, int _iRetCount, typed_list &out)
         return Function::OK;
     }
 
-
     if (iRhs > 2)
     {
         int iPos = iRhs - 1;
         if (in[iPos]->isString() == false)
         {
+            closeFile(in[0], iID);
             Scierror(999, _("%s: Wrong type for input argument #%d : A string expected.\n"), "write", iRhs);
             return Function::Error;
         }
@@ -142,6 +140,7 @@ Function::ReturnValue sci_write(typed_list &in, int _iRetCount, typed_list &out)
         String* pSFormat = in[iPos]->getAs<String>();
         if (pSFormat->isScalar() == false)
         {
+            closeFile(in[0], iID);
             Scierror(999, _("%s: Wrong type for input argument #%d : A string expected.\n"), "write", iRhs);
             return Function::Error;
         }
@@ -149,30 +148,13 @@ Function::ReturnValue sci_write(typed_list &in, int _iRetCount, typed_list &out)
         //checkformat
         pstFormat = wide_string_to_UTF8(pSFormat->get(0));
 
-        char cTypeData = checkformat(pstFormat);
-        if (cTypeData == 0)
+        itTypeOfData = checkformat(pstFormat);
+        if (itTypeOfData == InternalType::ScilabNull)
         {
+            closeFile(in[0], iID);
             Scierror(999, _("Incorrect file or format.\n"));
             return Function::Error;
         }
-        switch (cTypeData)
-        {
-            case '1':
-                itTypeOfData = types::InternalType::ScilabDouble;
-                break;
-            case '2':
-                itTypeOfData = types::InternalType::ScilabInt32;
-                break;
-            case '3':
-                itTypeOfData = types::InternalType::ScilabBool;
-                break;
-            case '4':
-                itTypeOfData = types::InternalType::ScilabString;
-                break;
-            default:
-                break;
-        }
-
     }
     else
     {
@@ -181,48 +163,36 @@ Function::ReturnValue sci_write(typed_list &in, int _iRetCount, typed_list &out)
             case types::InternalType::ScilabInt32:
             {
                 itTypeOfData = types::InternalType::ScilabInt32;
-                pstFormat = (char*)MALLOC(sizeof(char) * (strlen("(%d(1x,I4))\0") + (int)log10(iCols) + 2));
-                sprintf(pstFormat, "(%d(1x,I4))\0", iCols);
+                pstFormat = (char*)MALLOC(sizeof(char) * (strlen("(%d(1x,I4))") + (int)log10(iCols) + 2));
+                sprintf(pstFormat, "(%d(1x,I4))", iCols);
                 break;
             }
             case types::InternalType::ScilabDouble:
             {
                 if (iID == 6)
                 {
-                    pstFormat = (char*)MALLOC(sizeof(char) * (strlen("((1x,1pd17.10))\0") + (int)log10(iCols) + 2));
-                    sprintf(pstFormat, "(%d(1x,1pd17.10))\0", iCols);
+                    pstFormat = (char*)MALLOC(sizeof(char) * (strlen("((1x,1pd17.10))") + (int)log10(iCols) + 2));
+                    sprintf(pstFormat, "(%d(1x,1pd17.10))", iCols);
                 }
                 else
                 {
-                    pstFormat = (char*)MALLOC(sizeof(char) * (strlen("((1x,1pd17.10))\0") + (int)log10(iCols) + 2));
-                    sprintf(pstFormat, "(%d(1x,1pd17.10))\0", iCols);
+                    pstFormat = (char*)MALLOC(sizeof(char) * (strlen("((1x,1pd17.10))") + (int)log10(iCols) + 2));
+                    sprintf(pstFormat, "(%d(1x,1pd17.10))", iCols);
                 }
                 break;
             }
             case types::InternalType::ScilabString:
             {
                 itTypeOfData = types::InternalType::ScilabString;
-                pstFormat = (char*)MALLOC(sizeof(char) * (strlen("(a)\0") + 1));
-                sprintf(pstFormat, "(a)\0");
+                pstFormat = (char*)MALLOC(sizeof(char) * (strlen("(a)") + 1));
+                sprintf(pstFormat, "(a)");
                 break;
             }
             default:
             {
+                closeFile(in[0], iID);
                 Scierror(999, _("%s: Wrong type for input argument #%d : A string expected.\n"), "write", 2);
-
-                //close file
-                if (in[0]->isString())
-                {
-                    int piMode[2] = { 0, 0 };
-                    String* pSPath = in[0]->getAs<String>();
-                    char* pstFilename = wide_string_to_UTF8(pSPath->get(0));
-                    int  close = -iID;
-                    int iErr = C2F(clunit)(&close, pstFilename, piMode, (int)strlen(pstFilename));
-                    FREE(pstFilename);
-                }
-
                 return Function::Error;
-                break;
             }
         }
     }
@@ -246,8 +216,6 @@ Function::ReturnValue sci_write(typed_list &in, int _iRetCount, typed_list &out)
                         C2F(writestringfile)(&iID, pstFormat, pd, &error, (int)strlen(pstFormat), (int)strlen(pd));
                         FREE(pd);
                     }
-
-
                 }
                 break;
                 case types::InternalType::ScilabInt32:
@@ -290,9 +258,7 @@ Function::ReturnValue sci_write(typed_list &in, int _iRetCount, typed_list &out)
                         }
 
                         delete[] pd;
-
                     }
-
                 }
                 break;
                 case types::InternalType::ScilabDouble:
@@ -339,39 +305,19 @@ Function::ReturnValue sci_write(typed_list &in, int _iRetCount, typed_list &out)
                 }
                 break;
                 default:
+                {
                     Scierror(999, _("%s: Wrong type for input argument #%d : A string expected.\n"), "write", 2);
-
-                    //close file
-                    if (in[0]->isString())
-                    {
-                        int piMode[2] = { 0, 0 };
-                        String* pSPath = in[0]->getAs<String>();
-                        char* pstFilename = wide_string_to_UTF8(pSPath->get(0));
-                        int  close = -iID;
-                        int iErr = C2F(clunit)(&close, pstFilename, piMode, (int)strlen(pstFilename));
-                        FREE(pstFilename);
-                    }
-
+                    closeFile(in[0], iID);
                     return Function::Error;
-                    break;
+                }
             }
 
             //close file
-            if (in[0]->isString())
-            {
-                int piMode[2] = { 0, 0 };
-                String* pSPath = in[0]->getAs<String>();
-                char* pstFilename = wide_string_to_UTF8(pSPath->get(0));
-                int  close = -iID;
-                int iErr = C2F(clunit)(&close, pstFilename, piMode, (int)strlen(pstFilename));
-                FREE(pstFilename);
-            }
-
+            closeFile(in[0], iID);
         }
         else
         {
             //direct
-
             int iConsoleWidth = ConfigVariable::getConsoleWidth();
             switch (in[1]->getType())
             {
@@ -385,8 +331,6 @@ Function::ReturnValue sci_write(typed_list &in, int _iRetCount, typed_list &out)
                         C2F(writestring)(pstFormat, pd, &error, (int)strlen(pstFormat), (int)strlen(pd));
                         FREE(pd);
                     }
-
-
                 }
                 break;
                 case types::InternalType::ScilabInt32 :
@@ -476,17 +420,13 @@ Function::ReturnValue sci_write(typed_list &in, int _iRetCount, typed_list &out)
                 }
                 break;
                 default:
+                {
                     Scierror(999, _("%s: Wrong type for input argument #%d : A string expected.\n"), "write", 2);
                     return Function::Error;
-                    break;
+                }
             }
-
         }
     }
-    else
-    {
-
-    }
 
     if (pstFormat)
     {
@@ -501,61 +441,3 @@ Function::ReturnValue sci_write(typed_list &in, int _iRetCount, typed_list &out)
 
     return Function::OK;
 }
-
-int checkformat(char* format)
-{
-    char type1[] = { 'i', 'f', 'e', 'd', 'g', 'l', 'a', 'I', 'F', 'E', 'D', 'G', 'L', 'A' };
-    char type2[] = { '2', '1', '1', '1', '1', '3', '4', '2', '1', '1', '1', '1', '3', '4' };
-    int ret = 0;
-    int size = (int)strlen(format);
-    int count = 0;
-    bool isString = false;
-
-    if (size < 2 || format[0] != '(' || format[size - 1] != ')')
-    {
-        return 0;
-    }
-
-    for (int i = 1; i < size - 1; i++)
-    {
-        char c = format[i];
-
-        if (c == '\'')
-        {
-            isString = !isString;
-        }
-
-        if (isString)
-        {
-            if (count == 0)
-            {
-                count++;
-            }
-            else
-            {
-                count--;
-            }
-            continue;
-        }
-
-        for (int j = 0; j < sizeof(type1); j++)
-        {
-            if (c == type1[j])
-            {
-                if (ret == 0)
-                {
-                    ret = type2[j];
-                }
-
-                if (type2[j] != ret)
-                {
-                    return 0;
-                }
-
-                break;
-            }
-        }
-    }
-
-    return ret;
-}
index e068efd..025c6e9 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup Label="ProjectConfigurations">
     <ProjectConfiguration Include="Debug|Win32">
     <ClCompile Include="..\..\sci_gateway\cpp\sci_load.cpp" />
     <ClCompile Include="..\..\sci_gateway\cpp\sci_unix.cpp" />
     <ClCompile Include="loadlib.cpp" />
+    <ClCompile Include="readwrite.cpp" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\includes\dynlib_io_gw.h" />
     <ClInclude Include="..\..\includes\io_gw.hxx" />
     <ClInclude Include="loadlib.hxx" />
+    <ClInclude Include="readwrite.hxx" />
   </ItemGroup>
   <ItemGroup>
     <Library Include="..\..\..\..\bin\blasplus.lib" />
index 563b7c7..a2f6058 100644 (file)
@@ -75,6 +75,9 @@
     <ClCompile Include="..\..\sci_gateway\cpp\sci_read.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="readwrite.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\includes\dynlib_io_gw.h">
@@ -86,6 +89,9 @@
     <ClInclude Include="loadlib.hxx">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="readwrite.hxx">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <Library Include="..\..\..\..\bin\blasplus.lib" />
diff --git a/scilab/modules/io/src/cpp/readwrite.cpp b/scilab/modules/io/src/cpp/readwrite.cpp
new file mode 100644 (file)
index 0000000..219afec
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2015 - Scilab Enterprises - Cedric Delamarre
+ *
+ * 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.1-en.txt
+ *
+ */
+
+#include "readwrite.hxx"
+#include "string.hxx"
+
+extern "C"
+{
+    extern int C2F(clunit)(int*, char const*, int*, int);
+}
+/*--------------------------------------------------------------------------*/
+types::InternalType::ScilabType checkformat(const char* format)
+{
+    const char type1[] =
+    {
+        'i', 'f', 'e',
+        'd', 'g', 'l',
+        'a', 'I', 'F',
+        'E', 'D', 'G',
+        'L', 'A'
+    };
+    const types::InternalType::ScilabType type2[] =
+    {
+        types::InternalType::ScilabInt32, types::InternalType::ScilabDouble, types::InternalType::ScilabDouble,
+        types::InternalType::ScilabDouble, types::InternalType::ScilabDouble, types::InternalType::ScilabBool,
+        types::InternalType::ScilabString, types::InternalType::ScilabInt32, types::InternalType::ScilabDouble,
+        types::InternalType::ScilabDouble, types::InternalType::ScilabDouble, types::InternalType::ScilabDouble,
+        types::InternalType::ScilabBool, types::InternalType::ScilabString
+    };
+
+    int size = (int)strlen(format);
+    bool isString = false;
+    types::InternalType::ScilabType previousType = types::InternalType::ScilabNull;
+
+    if (size < 2 || format[0] != '(' || format[size - 1] != ')')
+    {
+        return types::InternalType::ScilabNull;
+    }
+
+    for (int i = 1; i < size - 1; ++i)
+    {
+        char c = format[i];
+
+        if (c == '\'')
+        {
+            isString = !isString;
+        }
+
+        //while we are in string continue
+        if (isString)
+        {
+            continue;
+        }
+
+        for (int j = 0; j < sizeof(type1); j++)
+        {
+            if (c == type1[j])
+            {
+                if (previousType == types::InternalType::ScilabNull)
+                {
+                    previousType = type2[j];
+                }
+
+                //must have same format for all values
+                if (type2[j] != previousType)
+                {
+                    return types::InternalType::ScilabNull;
+                }
+
+                break;
+            }
+        }
+    }
+
+    return previousType;
+}
+/*--------------------------------------------------------------------------*/
+void closeFile(types::InternalType* _pIT, int _iID)
+{
+    if (_pIT->isString())
+    {
+        int piMode[2] = { 0, 0 };
+        types::String* pSPath = _pIT->getAs<types::String>();
+        char* pstFilename = wide_string_to_UTF8(pSPath->get(0));
+        int  close = -_iID;
+        int iErr = C2F(clunit)(&close, pstFilename, piMode, (int)strlen(pstFilename));
+        FREE(pstFilename);
+    }
+}
+/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/io/src/cpp/readwrite.hxx b/scilab/modules/io/src/cpp/readwrite.hxx
new file mode 100644 (file)
index 0000000..81fe52c
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2015 - Scilab Enterprises - Cedric Delamarre
+*
+* 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
+*
+*/
+
+#ifndef __READWRITE_H__
+#define __READWRITE_H__
+
+#include "internal.hxx"
+
+types::InternalType::ScilabType checkformat(const char* format);
+void closeFile(types::InternalType* _pIT, int _iID);
+
+
+#endif /* !__READWRITE_H__ */
diff --git a/scilab/modules/io/tests/unit_tests/save_double_ref_Linux b/scilab/modules/io/tests/unit_tests/save_double_ref_Linux
new file mode 100644 (file)
index 0000000..ebe6a98
--- /dev/null
@@ -0,0 +1,5 @@
+  0.21132486546412110       0.62839178834110498       0.56084860628470778     
+  0.75604385416954756       0.84974523587152362       0.66235693730413914     
+   2.2113462910056114E-004  0.68573101982474327       0.72635067673400044     
+  0.33032709173858166       0.87821648130193353       0.19851438421756029     
+  0.66538110421970487        6.8374036811292171E-002  0.54425731627270579     
diff --git a/scilab/modules/io/tests/unit_tests/save_double_ref_windows b/scilab/modules/io/tests/unit_tests/save_double_ref_windows
new file mode 100644 (file)
index 0000000..91f7c8e
--- /dev/null
@@ -0,0 +1,5 @@
+  0.211324865464121       0.628391788341105       0.560848606284708     
+  0.756043854169548       0.849745235871524       0.662356937304139     
+  2.211346291005611E-004  0.685731019824743       0.726350676734000     
+  0.330327091738582       0.878216481301934       0.198514384217560     
+  0.665381104219705       6.837403681129217E-002  0.544257316272706     
diff --git a/scilab/modules/io/tests/unit_tests/save_int_ref_Linux b/scilab/modules/io/tests/unit_tests/save_int_ref_Linux
new file mode 100644 (file)
index 0000000..566133c
--- /dev/null
@@ -0,0 +1,5 @@
+   1.0000000000000000        8.0000000000000000        2.0000000000000000        6.0000000000000000        1.0000000000000000        0.0000000000000000        9.0000000000000000     
+   9.0000000000000000        7.0000000000000000        9.0000000000000000        9.0000000000000000        8.0000000000000000        8.0000000000000000        3.0000000000000000     
+   6.0000000000000000        1.0000000000000000        8.0000000000000000        0.0000000000000000        3.0000000000000000        5.0000000000000000        1.0000000000000000     
+   2.0000000000000000        7.0000000000000000        2.0000000000000000        2.0000000000000000        5.0000000000000000        2.0000000000000000        9.0000000000000000     
+   5.0000000000000000        3.0000000000000000        8.0000000000000000        7.0000000000000000        5.0000000000000000        9.0000000000000000        7.0000000000000000     
diff --git a/scilab/modules/io/tests/unit_tests/save_int_ref_windows b/scilab/modules/io/tests/unit_tests/save_int_ref_windows
new file mode 100644 (file)
index 0000000..a0dceb6
--- /dev/null
@@ -0,0 +1,15 @@
+   1.00000000000000        8.00000000000000        2.00000000000000     
+   6.00000000000000        1.00000000000000       0.000000000000000E+000
+   9.00000000000000     
+   9.00000000000000        7.00000000000000        9.00000000000000     
+   9.00000000000000        8.00000000000000        8.00000000000000     
+   3.00000000000000     
+   6.00000000000000        1.00000000000000        8.00000000000000     
+  0.000000000000000E+000   3.00000000000000        5.00000000000000     
+   1.00000000000000     
+   2.00000000000000        7.00000000000000        2.00000000000000     
+   2.00000000000000        5.00000000000000        2.00000000000000     
+   9.00000000000000     
+   5.00000000000000        3.00000000000000        8.00000000000000     
+   7.00000000000000        5.00000000000000        9.00000000000000     
+   7.00000000000000     
diff --git a/scilab/modules/io/tests/unit_tests/write.dia.ref b/scilab/modules/io/tests/unit_tests/write.dia.ref
deleted file mode 100644 (file)
index bdd1081..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-// =============================================================================
-// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) 2015 - Scilab Enterprises - Sylvain GENIN
-//
-//  This file is distributed under the same license as the Scilab package.
-// =============================================================================
-//
-path_double = TMPDIR + "/save_double";
-path_int = TMPDIR + "/save_int";
-path_int2 = TMPDIR + "/save_int2";
-path_int3 = TMPDIR + "/save_int3";
-path_int4 = TMPDIR + "/save_int4";
-path_logic = TMPDIR + "/save_logic";
-path_string = TMPDIR + "/save_string";
-rand("seed",0);
-A=rand(5,3);
-write(6,A,"("" | "",3(f10.3,"" | ""))")
- |      0.211 |      0.628 |      0.561 |
- |      0.756 |      0.850 |      0.662 |
- |      0.000 |      0.686 |      0.726 |
- |      0.330 |      0.878 |      0.199 |
- |      0.665 |      0.068 |      0.544 |
-write(6,rand(5,7)*10)
-  2.3207478970D+00  3.0760907428D+00  2.9222666379D+00  5.0153415976D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
-  9.1847078316D+00  2.8064980218D+00  6.8568959553D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
-  2.3122371966D+00  9.3296162132D+00  5.6642488157D+00  4.3685875833D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
-  4.3733433355D-01  1.2800584640D+00  1.5312166838D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
-  2.1646326315D+00  2.1460078610D+00  4.8264719732D+00  2.6931248093D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
-  4.8185089324D+00  7.7831285959D+00  6.9708506018D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
-  8.8338878145D+00  3.1264199689D+00  3.3217189135D+00  6.3257448655D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
-  2.6395560009D+00  2.1190304495D+00  8.4155184263D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
-  6.5251349472D+00  3.6163610080D+00  5.9350947011D+00  4.0519540152D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
-  4.1481037065D+00  1.1213546665D+00  4.0620247554D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
-write(6,round(rand(5,7)))
-  0.0000000000D+00  1.0000000000D+00  0.0000000000D+00  1.0000000000D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
-  1.0000000000D+00  0.0000000000D+00  1.0000000000D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
-  1.0000000000D+00  1.0000000000D+00  1.0000000000D+00  0.0000000000D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
-  0.0000000000D+00  1.0000000000D+00  0.0000000000D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
-  0.0000000000D+00  1.0000000000D+00  1.0000000000D+00  0.0000000000D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
-  0.0000000000D+00  0.0000000000D+00  0.0000000000D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
-  0.0000000000D+00  1.0000000000D+00  0.0000000000D+00  0.0000000000D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
-  1.0000000000D+00  0.0000000000D+00  1.0000000000D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
-  1.0000000000D+00  0.0000000000D+00  0.0000000000D+00  1.0000000000D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
-  1.0000000000D+00  1.0000000000D+00  0.0000000000D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
-write(6,int(rand(5,7)*10))
-  2.0000000000D+00  6.0000000000D+00  6.0000000000D+00  5.0000000000D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
-  1.0000000000D+00  7.0000000000D+00  6.0000000000D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
-  8.0000000000D+00  9.0000000000D+00  8.0000000000D+00  5.0000000000D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
-  7.0000000000D+00  0.0000000000D+00  1.0000000000D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
-  8.0000000000D+00  0.0000000000D+00  0.0000000000D+00  8.0000000000D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
-  2.0000000000D+00  5.0000000000D+00  6.0000000000D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
-  5.0000000000D+00  7.0000000000D+00  8.0000000000D+00  0.0000000000D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
-  5.0000000000D+00  3.0000000000D+00  6.0000000000D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
-  9.0000000000D+00  4.0000000000D+00  9.0000000000D+00  5.0000000000D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
-  9.0000000000D+00  2.0000000000D+00  3.0000000000D+00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
-write(6,"aaa")
-aaa
-write(6,["aaa","bbb";"ccccc","read me"])
-aaa
-ccccc
-bbb
-read me
-write(6,int(rand(5,7)*10),"("" | "",7(f10.3,"" | ""))")
- |      0.000 |      4.000 |      7.000 |      4.000 |      9.000 |      4.000 |      4.000 |
- |      5.000 |      2.000 |      5.000 |      7.000 |      5.000 |      7.000 |      2.000 |
- |      3.000 |      0.000 |      2.000 |      8.000 |      5.000 |      7.000 |      9.000 |
- |      2.000 |      6.000 |      6.000 |      2.000 |      5.000 |      9.000 |      1.000 |
- |      5.000 |      3.000 |      0.000 |      4.000 |      5.000 |      8.000 |      4.000 |
-//pass from  scilab 6.0
-write(6,int32(rand(5,7)*10))
-    3    1    0    2    8    6    0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
-    0    0    1    5    8    7    9                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
-    5    8    4    2    2    3    2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
-    8    0    7    4    4    7    0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
-    6    8    9    9    3    5    8                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
-  write(path_int,int(rand(5,7)*10));
-  fd = mopen(path_int, "rt");
- solution = [ 
- "   1.00000000000000        8.00000000000000        2.00000000000000     ";
- "   6.00000000000000        1.00000000000000       0.000000000000000E+000";
- "   9.00000000000000     ";
- "   9.00000000000000        7.00000000000000        9.00000000000000     ";
- "   9.00000000000000        8.00000000000000        8.00000000000000     ";
- "   3.00000000000000     ";
- "   6.00000000000000        1.00000000000000        8.00000000000000     ";
- "  0.000000000000000E+000   3.00000000000000        5.00000000000000     ";
- "   1.00000000000000     ";
- "   2.00000000000000        7.00000000000000        2.00000000000000     ";
- "   2.00000000000000        5.00000000000000        2.00000000000000     ";
- "   9.00000000000000     ";
- "   5.00000000000000        3.00000000000000        8.00000000000000     ";
- "   7.00000000000000        5.00000000000000        9.00000000000000     ";
- "   7.00000000000000     "];
- result = mgetl(fd);
- assert_checkequal(result, solution);
- mclose(fd);
- mdelete(path_int);
- write(path_double,A);
- fd = mopen(path_double, "rt");
- solution = [
- "  0.211324865464121       0.628391788341105       0.560848606284708     ";
- "  0.756043854169548       0.849745235871524       0.662356937304139     ";
- "  2.211346291005611E-004  0.685731019824743       0.726350676734000     ";
- "  0.330327091738582       0.878216481301934       0.198514384217560     ";
- "  0.665381104219705       6.837403681129217E-002  0.544257316272706     "];
- result = mgetl(fd);
- assert_checkequal(result, solution);
- mclose(fd);
- refMsg = msprintf(_("File ""%s"" already exists or directory write access denied.\n"), path_double);
- assert_checkerror("write(path_double,rand(5,7));", refMsg);
- mdelete(path_double);
- refMsg = msprintf(_("%s: Wrong type for input argument #%d : A string expected.\n"), "write", 2);
- assert_checkerror("write(path_logic,[%t, %f; %f, %f]);", refMsg);
- mdelete(path_logic);
- write(path_string,"aaa");
- fd = mopen(path_string, "rt");
- solution = "aaa";
- result = mgetl(fd);
- assert_checkequal(result, solution);
- mclose(fd);
- mdelete(path_string);
- write(path_string,["aaa","bbb";"cccc","scilab"]);
- fd = mopen(path_string, "rt");
- solution = ["aaa";"cccc";"bbb";"scilab"];
- result = mgetl(fd);
- assert_checkequal(result, solution);
- mclose(fd);
- mdelete(path_string);
- write(path_int3,1:10,"(10(i))");
- fd = mopen(path_int3, "rt");
- solution = "           1           2           3           4           5           6           7           8           9          10";
- result = mgetl(fd);
- assert_checkequal(result, solution);
- mclose(fd);
- mdelete(path_int3);
- write(path_int4,round(rand(5,7)*10),"(10(i))");
- fd = mopen(path_int4, "rt");
- solution = [
-"           3           4           0           8           0           1           9";
-"           6           1           3           1           9           1           1";
-"           4           3           2           9           8           5           4";
-"          10           1           2           5           4           4           9";
-"           3           8           3           3           8           6           0"];
- result = mgetl(fd);
- assert_checkequal(result, solution);
- mclose(fd);
- mdelete(path_int4);
index a792feb..5d7c5d2 100644 (file)
@@ -14,6 +14,20 @@ path_int4 = TMPDIR + "/save_int4";
 path_logic = TMPDIR + "/save_logic";
 path_string = TMPDIR + "/save_string";
 
+tst_path = "SCI/modules/io/tests/unit_tests/";
+path_double_ref = tst_path+"/save_double_ref_"+getos();
+path_int_ref = tst_path + "/save_int_ref_"+getos();
+
+function check_file(computed_file, ref_file)
+    fd = mopen(computed_file, "r");
+    fdr = mopen(ref_file, "r");
+    computed = mgetl(fd);
+    expected = mgetl(fdr);
+    assert_checkequal(expected, computed);
+    mclose(fd);
+    mclose(fdr);
+endfunction
+
 rand("seed",0);
 A=rand(5,3);
 
@@ -28,40 +42,11 @@ write(6,int(rand(5,7)*10),"("" | "",7(f10.3,"" | ""))")
 write(6,int32(rand(5,7)*10))
 
 write(path_int,int(rand(5,7)*10));
-fd = mopen(path_int, "rt");
-solution = [
-"   1.00000000000000        8.00000000000000        2.00000000000000     ";
-"   6.00000000000000        1.00000000000000       0.000000000000000E+000";
-"   9.00000000000000     ";
-"   9.00000000000000        7.00000000000000        9.00000000000000     ";
-"   9.00000000000000        8.00000000000000        8.00000000000000     ";
-"   3.00000000000000     ";
-"   6.00000000000000        1.00000000000000        8.00000000000000     ";
-"  0.000000000000000E+000   3.00000000000000        5.00000000000000     ";
-"   1.00000000000000     ";
-"   2.00000000000000        7.00000000000000        2.00000000000000     ";
-"   2.00000000000000        5.00000000000000        2.00000000000000     ";
-"   9.00000000000000     ";
-"   5.00000000000000        3.00000000000000        8.00000000000000     ";
-"   7.00000000000000        5.00000000000000        9.00000000000000     ";
-"   7.00000000000000     "];
-result = mgetl(fd);
-assert_checkequal(result, solution);
-mclose(fd);
-
+check_file(path_int, path_int_ref);
 mdelete(path_int);
 
 write(path_double,A);
-fd = mopen(path_double, "rt");
-solution = [
-"  0.211324865464121       0.628391788341105       0.560848606284708     ";
-"  0.756043854169548       0.849745235871524       0.662356937304139     ";
-"  2.211346291005611E-004  0.685731019824743       0.726350676734000     ";
-"  0.330327091738582       0.878216481301934       0.198514384217560     ";
-"  0.665381104219705       6.837403681129217E-002  0.544257316272706     "];
-result = mgetl(fd);
-assert_checkequal(result, solution);
-mclose(fd);
+check_file(path_double, path_double_ref);
 
 refMsg = msprintf(_("File ""%s"" already exists or directory write access denied.\n"), path_double);
 assert_checkerror("write(path_double,rand(5,7));", refMsg);
@@ -91,23 +76,23 @@ mclose(fd);
 
 mdelete(path_string);
 
-write(path_int3,1:10,"(10(i))");
+write(path_int3,1:10,"(10(i3))");
 fd = mopen(path_int3, "rt");
-solution = "           1           2           3           4           5           6           7           8           9          10";
+solution = "  1  2  3  4  5  6  7  8  9 10";
 result = mgetl(fd);
 assert_checkequal(result, solution);
 mclose(fd);
 
 mdelete(path_int3);
 
-write(path_int4,round(rand(5,7)*10),"(10(i))");
+write(path_int4,round(rand(5,7)*10),"(10(i3))");
 fd = mopen(path_int4, "rt");
 solution = [
-"           3           4           0           8           0           1           9";
-"           6           1           3           1           9           1           1";
-"           4           3           2           9           8           5           4";
-"          10           1           2           5           4           4           9";
-"           3           8           3           3           8           6           0"];
+"  3  4  0  8  0  1  9";
+"  6  1  3  1  9  1  1";
+"  4  3  2  9  8  5  4";
+" 10  1  2  5  4  4  9";
+"  3  8  3  3  8  6  0"];
 result = mgetl(fd);
 assert_checkequal(result, solution);
 mclose(fd);
diff --git a/scilab/modules/io/tests/unit_tests/write.unix.dia.ref b/scilab/modules/io/tests/unit_tests/write.unix.dia.ref
new file mode 100644 (file)
index 0000000..58a9c25
--- /dev/null
@@ -0,0 +1,131 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2015 - Scilab Enterprises - Sylvain GENIN
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+path_double = TMPDIR + "/save_double";
+path_int = TMPDIR + "/save_int";
+path_int2 = TMPDIR + "/save_int2";
+path_int3 = TMPDIR + "/save_int3";
+path_int4 = TMPDIR + "/save_int4";
+path_logic = TMPDIR + "/save_logic";
+path_string = TMPDIR + "/save_string";
+tst_path = "SCI/modules/io/tests/unit_tests/";
+path_double_ref = tst_path+"/save_double_ref_"+getos();
+path_int_ref = tst_path + "/save_int_ref_"+getos();
+function check_file(computed_file, ref_file)
+    fd = mopen(computed_file, "r");
+    fdr = mopen(ref_file, "r");
+    computed = mgetl(fd);
+    expected = mgetl(fdr);
+    assert_checkequal(expected, computed);
+    mclose(fd);
+    mclose(fdr);
+endfunction
+rand("seed",0);
+A=rand(5,3);
+write(6,A,"("" | "",3(f10.3,"" | ""))")
+ |      0.211 |      0.628 |      0.561 |
+ |      0.756 |      0.850 |      0.662 |
+ |      0.000 |      0.686 |      0.726 |
+ |      0.330 |      0.878 |      0.199 |
+ |      0.665 |      0.068 |      0.544 |
+write(6,rand(5,7)*10)
+   2.3207478970D+00  3.0760907428D+00  2.9222666379D+00  5.0153415976D+0
+   9.1847078316D+00  2.8064980218D+00  6.8568959553D+00                                                                                         
+   2.3122371966D+00  9.3296162132D+00  5.6642488157D+00  4.3685875833D+0
+   4.3733433355D-01  1.2800584640D+00  1.5312166838D+00                                                                                         
+   2.1646326315D+00  2.1460078610D+00  4.8264719732D+00  2.6931248093D+0
+   4.8185089324D+00  7.7831285959D+00  6.9708506018D+00                                                                                         
+   8.8338878145D+00  3.1264199689D+00  3.3217189135D+00  6.3257448655D+0
+   2.6395560009D+00  2.1190304495D+00  8.4155184263D+00                                                                                         
+   6.5251349472D+00  3.6163610080D+00  5.9350947011D+00  4.0519540152D+0
+   4.1481037065D+00  1.1213546665D+00  4.0620247554D+00                                                                                         
+write(6,round(rand(5,7)))
+   0.0000000000D+00  1.0000000000D+00  0.0000000000D+00  1.0000000000D+0
+   1.0000000000D+00  0.0000000000D+00  1.0000000000D+00                                                                                         
+   1.0000000000D+00  1.0000000000D+00  1.0000000000D+00  0.0000000000D+0
+   0.0000000000D+00  1.0000000000D+00  0.0000000000D+00                                                                                         
+   0.0000000000D+00  1.0000000000D+00  1.0000000000D+00  0.0000000000D+0
+   0.0000000000D+00  0.0000000000D+00  0.0000000000D+00