mfprintf, mfscanf, mscanf, msscanf added. 87/3787/18
cedric Delamarre [Wed, 13 Apr 2011 07:31:15 +0000 (09:31 +0200)]
Change-Id: If5587ae1dfd5aaeb5505bc43cb791dfeee8b1b32

43 files changed:
scilab/modules/fileio/Makefile.am
scilab/modules/fileio/Makefile.in
scilab/modules/fileio/fileio.vcxproj
scilab/modules/fileio/fileio.vcxproj.filters
scilab/modules/fileio/includes/do_xxscanf.h [moved from scilab/modules/fileio/src/c/do_xxscanf.h with 83% similarity]
scilab/modules/fileio/includes/fileio_gw.hxx
scilab/modules/fileio/includes/gw_fileio.h
scilab/modules/fileio/includes/scanf_functions.h [moved from scilab/modules/fileio/src/c/scanf_functions.h with 82% similarity]
scilab/modules/fileio/sci_gateway/c/gw_fileio.c
scilab/modules/fileio/sci_gateway/c/sci_mfprintf.c [deleted file]
scilab/modules/fileio/sci_gateway/c/sci_mfscanf.c [deleted file]
scilab/modules/fileio/sci_gateway/c/sci_mscanf.c [deleted file]
scilab/modules/fileio/sci_gateway/c/sci_msscanf.c [deleted file]
scilab/modules/fileio/sci_gateway/cpp/fileio_gw.cpp
scilab/modules/fileio/sci_gateway/cpp/fileio_gw.vcxproj
scilab/modules/fileio/sci_gateway/cpp/fileio_gw.vcxproj.filters
scilab/modules/fileio/sci_gateway/cpp/sci_get_absolute_file_path.cpp
scilab/modules/fileio/sci_gateway/cpp/sci_mfprintf.cpp [new file with mode: 0644]
scilab/modules/fileio/sci_gateway/cpp/sci_mfscanf.cpp [new file with mode: 0644]
scilab/modules/fileio/sci_gateway/cpp/sci_mputstr.cpp
scilab/modules/fileio/sci_gateway/cpp/sci_mscanf.cpp [new file with mode: 0644]
scilab/modules/fileio/sci_gateway/cpp/sci_msscanf.cpp [new file with mode: 0644]
scilab/modules/fileio/src/c/do_xxscanf.c
scilab/modules/fileio/src/c/getrelativefilename.c
scilab/modules/fileio/src/c/getshortpathname.c
scilab/modules/fileio/src/c/scanf_functions.c
scilab/modules/fileio/src/cpp/mgetstr.cpp
scilab/modules/fileio/src/cpp/mputl.cpp
scilab/modules/fileio/src/cpp/mputl.h
scilab/modules/fileio/src/cpp/scilab_sscanf.cpp [new file with mode: 0644]
scilab/modules/fileio/src/cpp/scilab_sscanf.hxx [new file with mode: 0644]
scilab/modules/fileio/tests/benchmarks/bench_msscanf.tst [new file with mode: 0644]
scilab/modules/fileio/tests/unit_tests/mfscanf.tst
scilab/modules/fileio/tests/unit_tests/msscanf.tst
scilab/modules/output_stream/includes/scilab_sprintf.hxx
scilab/modules/output_stream/src/cpp/scilab_sprintf.cpp
scilab/modules/string/Makefile.am
scilab/modules/string/Makefile.in
scilab/modules/string/includes/os_wcstok.h [new file with mode: 0644]
scilab/modules/string/src/c/os_wcstok.c [new file with mode: 0644]
scilab/modules/string/src/c/string.vcxproj
scilab/modules/string/src/c/string.vcxproj.filters
scilab/modules/string/src/c/tokens.c

index b9fdd80..bde8333 100644 (file)
@@ -46,10 +46,6 @@ src/c/fprintfMat.c
 
 GATEWAY_C_SOURCES = \
 sci_gateway/c/gw_fileio.c \
-sci_gateway/c/sci_mfprintf.c \
-sci_gateway/c/sci_mscanf.c \
-sci_gateway/c/sci_msscanf.c \
-sci_gateway/c/sci_mfscanf.c \
 sci_gateway/c/sci_fprintfMat.c \
 sci_gateway/c/sci_fscanfMat.c \
 sci_gateway/c/sci_maxfiles.c \
@@ -92,8 +88,12 @@ GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_mclearerr.cpp \
        sci_gateway/cpp/sci_get_absolute_file_path.cpp \
        sci_gateway/cpp/sci_getrelativefilename.cpp \
-       sci_gateway/cpp/sci_pathsep.cpp
-
+       sci_gateway/cpp/sci_pathsep.cpp \
+       sci_gateway/cpp/sci_mfprintf.cpp \
+       sci_gateway/cpp/sci_mfscanf.cpp \
+       sci_gateway/cpp/sci_mscanf.cpp \
+       sci_gateway/cpp/sci_msscanf.cpp 
+               
 FILEIO_CPP_SOURCES = \
        src/cpp/expandPathVariable.cpp \
        src/cpp/mopen.cpp \
@@ -106,7 +106,8 @@ FILEIO_CPP_SOURCES = \
        src/cpp/filemanager.cpp \
        src/cpp/mseek.cpp \
        src/cpp/mtell.cpp \
-       src/cpp/newest.cpp
+       src/cpp/newest.cpp \
+       src/cpp/scilab_sscanf.cpp
 
 libscifileio_la_CPPFLAGS=      -I$(srcdir)/includes/ \
                                -I$(srcdir)/src/c/ \
@@ -122,6 +123,7 @@ libscifileio_la_CPPFLAGS=   -I$(srcdir)/includes/ \
                                -I$(top_srcdir)/modules/string/includes \
                                -I$(top_srcdir)/modules/system_env/includes \
                                -I$(top_srcdir)/modules/io/includes \
+                               -I$(top_srcdir)/modules/shell/includes \
                                $(HDF5_CFLAGS)
 
 libscifileio_la_CFLAGS=                -I$(srcdir)/includes/ \
index 623e4ac..e450ba8 100644 (file)
@@ -154,7 +154,8 @@ am__objects_2 = libscifileio_algo_la-expandPathVariable.lo \
        libscifileio_algo_la-mgetstr.lo \
        libscifileio_algo_la-filemanager.lo \
        libscifileio_algo_la-mseek.lo libscifileio_algo_la-mtell.lo \
-       libscifileio_algo_la-newest.lo
+       libscifileio_algo_la-newest.lo \
+       libscifileio_algo_la-scilab_sscanf.lo
 am_libscifileio_algo_la_OBJECTS = $(am__objects_1) $(am__objects_2)
 libscifileio_algo_la_OBJECTS = $(am_libscifileio_algo_la_OBJECTS)
 libscifileio_la_DEPENDENCIES = libscifileio-algo.la \
@@ -164,8 +165,6 @@ libscifileio_la_DEPENDENCIES = libscifileio-algo.la \
        $(top_builddir)/modules/output_stream/libscioutput_stream.la \
        $(top_builddir)/libs/libst/libscilibst.la
 am__objects_3 = libscifileio_la-gw_fileio.lo \
-       libscifileio_la-sci_mfprintf.lo libscifileio_la-sci_mscanf.lo \
-       libscifileio_la-sci_msscanf.lo libscifileio_la-sci_mfscanf.lo \
        libscifileio_la-sci_fprintfMat.lo \
        libscifileio_la-sci_fscanfMat.lo \
        libscifileio_la-sci_maxfiles.lo \
@@ -195,7 +194,9 @@ am__objects_4 = libscifileio_la-fileio_gw.lo \
        libscifileio_la-sci_mclearerr.lo \
        libscifileio_la-sci_get_absolute_file_path.lo \
        libscifileio_la-sci_getrelativefilename.lo \
-       libscifileio_la-sci_pathsep.lo
+       libscifileio_la-sci_pathsep.lo libscifileio_la-sci_mfprintf.lo \
+       libscifileio_la-sci_mfscanf.lo libscifileio_la-sci_mscanf.lo \
+       libscifileio_la-sci_msscanf.lo
 am_libscifileio_la_OBJECTS = $(am__objects_3) $(am__objects_4)
 libscifileio_la_OBJECTS = $(am_libscifileio_la_OBJECTS)
 libscifileio_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
@@ -530,10 +531,6 @@ src/c/fprintfMat.c
 
 GATEWAY_C_SOURCES = \
 sci_gateway/c/gw_fileio.c \
-sci_gateway/c/sci_mfprintf.c \
-sci_gateway/c/sci_mscanf.c \
-sci_gateway/c/sci_msscanf.c \
-sci_gateway/c/sci_mfscanf.c \
 sci_gateway/c/sci_fprintfMat.c \
 sci_gateway/c/sci_fscanfMat.c \
 sci_gateway/c/sci_maxfiles.c \
@@ -576,7 +573,11 @@ GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_mclearerr.cpp \
        sci_gateway/cpp/sci_get_absolute_file_path.cpp \
        sci_gateway/cpp/sci_getrelativefilename.cpp \
-       sci_gateway/cpp/sci_pathsep.cpp
+       sci_gateway/cpp/sci_pathsep.cpp \
+       sci_gateway/cpp/sci_mfprintf.cpp \
+       sci_gateway/cpp/sci_mfscanf.cpp \
+       sci_gateway/cpp/sci_mscanf.cpp \
+       sci_gateway/cpp/sci_msscanf.cpp 
 
 FILEIO_CPP_SOURCES = \
        src/cpp/expandPathVariable.cpp \
@@ -590,7 +591,8 @@ FILEIO_CPP_SOURCES = \
        src/cpp/filemanager.cpp \
        src/cpp/mseek.cpp \
        src/cpp/mtell.cpp \
-       src/cpp/newest.cpp
+       src/cpp/newest.cpp \
+       src/cpp/scilab_sscanf.cpp
 
 libscifileio_la_CPPFLAGS = -I$(srcdir)/includes/ \
                                -I$(srcdir)/src/c/ \
@@ -606,6 +608,7 @@ libscifileio_la_CPPFLAGS = -I$(srcdir)/includes/ \
                                -I$(top_srcdir)/modules/string/includes \
                                -I$(top_srcdir)/modules/system_env/includes \
                                -I$(top_srcdir)/modules/io/includes \
+                               -I$(top_srcdir)/modules/shell/includes \
                                $(HDF5_CFLAGS)
 
 libscifileio_la_CFLAGS = -I$(srcdir)/includes/ \
@@ -857,6 +860,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscifileio_algo_la-removedir.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscifileio_algo_la-scanf_functions.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscifileio_algo_la-scicurdir.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscifileio_algo_la-scilab_sscanf.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscifileio_algo_la-splitpath.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscifileio_la-fileio_gw.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscifileio_la-gw_fileio.Plo@am__quote@
@@ -1199,34 +1203,6 @@ libscifileio_la-gw_fileio.lo: sci_gateway/c/gw_fileio.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(libscifileio_la_CFLAGS) $(CFLAGS) -c -o libscifileio_la-gw_fileio.lo `test -f 'sci_gateway/c/gw_fileio.c' || echo '$(srcdir)/'`sci_gateway/c/gw_fileio.c
 
-libscifileio_la-sci_mfprintf.lo: sci_gateway/c/sci_mfprintf.c
-@am__fastdepCC_TRUE@   $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(libscifileio_la_CFLAGS) $(CFLAGS) -MT libscifileio_la-sci_mfprintf.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-sci_mfprintf.Tpo -c -o libscifileio_la-sci_mfprintf.lo `test -f 'sci_gateway/c/sci_mfprintf.c' || echo '$(srcdir)/'`sci_gateway/c/sci_mfprintf.c
-@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscifileio_la-sci_mfprintf.Tpo $(DEPDIR)/libscifileio_la-sci_mfprintf.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='sci_gateway/c/sci_mfprintf.c' object='libscifileio_la-sci_mfprintf.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(libscifileio_la_CFLAGS) $(CFLAGS) -c -o libscifileio_la-sci_mfprintf.lo `test -f 'sci_gateway/c/sci_mfprintf.c' || echo '$(srcdir)/'`sci_gateway/c/sci_mfprintf.c
-
-libscifileio_la-sci_mscanf.lo: sci_gateway/c/sci_mscanf.c
-@am__fastdepCC_TRUE@   $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(libscifileio_la_CFLAGS) $(CFLAGS) -MT libscifileio_la-sci_mscanf.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-sci_mscanf.Tpo -c -o libscifileio_la-sci_mscanf.lo `test -f 'sci_gateway/c/sci_mscanf.c' || echo '$(srcdir)/'`sci_gateway/c/sci_mscanf.c
-@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscifileio_la-sci_mscanf.Tpo $(DEPDIR)/libscifileio_la-sci_mscanf.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='sci_gateway/c/sci_mscanf.c' object='libscifileio_la-sci_mscanf.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(libscifileio_la_CFLAGS) $(CFLAGS) -c -o libscifileio_la-sci_mscanf.lo `test -f 'sci_gateway/c/sci_mscanf.c' || echo '$(srcdir)/'`sci_gateway/c/sci_mscanf.c
-
-libscifileio_la-sci_msscanf.lo: sci_gateway/c/sci_msscanf.c
-@am__fastdepCC_TRUE@   $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(libscifileio_la_CFLAGS) $(CFLAGS) -MT libscifileio_la-sci_msscanf.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-sci_msscanf.Tpo -c -o libscifileio_la-sci_msscanf.lo `test -f 'sci_gateway/c/sci_msscanf.c' || echo '$(srcdir)/'`sci_gateway/c/sci_msscanf.c
-@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscifileio_la-sci_msscanf.Tpo $(DEPDIR)/libscifileio_la-sci_msscanf.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='sci_gateway/c/sci_msscanf.c' object='libscifileio_la-sci_msscanf.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(libscifileio_la_CFLAGS) $(CFLAGS) -c -o libscifileio_la-sci_msscanf.lo `test -f 'sci_gateway/c/sci_msscanf.c' || echo '$(srcdir)/'`sci_gateway/c/sci_msscanf.c
-
-libscifileio_la-sci_mfscanf.lo: sci_gateway/c/sci_mfscanf.c
-@am__fastdepCC_TRUE@   $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(libscifileio_la_CFLAGS) $(CFLAGS) -MT libscifileio_la-sci_mfscanf.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-sci_mfscanf.Tpo -c -o libscifileio_la-sci_mfscanf.lo `test -f 'sci_gateway/c/sci_mfscanf.c' || echo '$(srcdir)/'`sci_gateway/c/sci_mfscanf.c
-@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscifileio_la-sci_mfscanf.Tpo $(DEPDIR)/libscifileio_la-sci_mfscanf.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='sci_gateway/c/sci_mfscanf.c' object='libscifileio_la-sci_mfscanf.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(libscifileio_la_CFLAGS) $(CFLAGS) -c -o libscifileio_la-sci_mfscanf.lo `test -f 'sci_gateway/c/sci_mfscanf.c' || echo '$(srcdir)/'`sci_gateway/c/sci_mfscanf.c
-
 libscifileio_la-sci_fprintfMat.lo: sci_gateway/c/sci_fprintfMat.c
 @am__fastdepCC_TRUE@   $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(libscifileio_la_CFLAGS) $(CFLAGS) -MT libscifileio_la-sci_fprintfMat.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-sci_fprintfMat.Tpo -c -o libscifileio_la-sci_fprintfMat.lo `test -f 'sci_gateway/c/sci_fprintfMat.c' || echo '$(srcdir)/'`sci_gateway/c/sci_fprintfMat.c
 @am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscifileio_la-sci_fprintfMat.Tpo $(DEPDIR)/libscifileio_la-sci_fprintfMat.Plo
@@ -1388,6 +1364,13 @@ libscifileio_algo_la-newest.lo: src/cpp/newest.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscifileio_algo_la-newest.lo `test -f 'src/cpp/newest.cpp' || echo '$(srcdir)/'`src/cpp/newest.cpp
 
+libscifileio_algo_la-scilab_sscanf.lo: src/cpp/scilab_sscanf.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscifileio_algo_la-scilab_sscanf.lo -MD -MP -MF $(DEPDIR)/libscifileio_algo_la-scilab_sscanf.Tpo -c -o libscifileio_algo_la-scilab_sscanf.lo `test -f 'src/cpp/scilab_sscanf.cpp' || echo '$(srcdir)/'`src/cpp/scilab_sscanf.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscifileio_algo_la-scilab_sscanf.Tpo $(DEPDIR)/libscifileio_algo_la-scilab_sscanf.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/scilab_sscanf.cpp' object='libscifileio_algo_la-scilab_sscanf.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscifileio_algo_la-scilab_sscanf.lo `test -f 'src/cpp/scilab_sscanf.cpp' || echo '$(srcdir)/'`src/cpp/scilab_sscanf.cpp
+
 libscifileio_la-fileio_gw.lo: sci_gateway/cpp/fileio_gw.cpp
 @am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscifileio_la-fileio_gw.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-fileio_gw.Tpo -c -o libscifileio_la-fileio_gw.lo `test -f 'sci_gateway/cpp/fileio_gw.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/fileio_gw.cpp
 @am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscifileio_la-fileio_gw.Tpo $(DEPDIR)/libscifileio_la-fileio_gw.Plo
@@ -1619,6 +1602,34 @@ libscifileio_la-sci_pathsep.lo: sci_gateway/cpp/sci_pathsep.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscifileio_la-sci_pathsep.lo `test -f 'sci_gateway/cpp/sci_pathsep.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_pathsep.cpp
 
+libscifileio_la-sci_mfprintf.lo: sci_gateway/cpp/sci_mfprintf.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscifileio_la-sci_mfprintf.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-sci_mfprintf.Tpo -c -o libscifileio_la-sci_mfprintf.lo `test -f 'sci_gateway/cpp/sci_mfprintf.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_mfprintf.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscifileio_la-sci_mfprintf.Tpo $(DEPDIR)/libscifileio_la-sci_mfprintf.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_mfprintf.cpp' object='libscifileio_la-sci_mfprintf.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscifileio_la-sci_mfprintf.lo `test -f 'sci_gateway/cpp/sci_mfprintf.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_mfprintf.cpp
+
+libscifileio_la-sci_mfscanf.lo: sci_gateway/cpp/sci_mfscanf.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscifileio_la-sci_mfscanf.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-sci_mfscanf.Tpo -c -o libscifileio_la-sci_mfscanf.lo `test -f 'sci_gateway/cpp/sci_mfscanf.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_mfscanf.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscifileio_la-sci_mfscanf.Tpo $(DEPDIR)/libscifileio_la-sci_mfscanf.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_mfscanf.cpp' object='libscifileio_la-sci_mfscanf.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscifileio_la-sci_mfscanf.lo `test -f 'sci_gateway/cpp/sci_mfscanf.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_mfscanf.cpp
+
+libscifileio_la-sci_mscanf.lo: sci_gateway/cpp/sci_mscanf.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscifileio_la-sci_mscanf.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-sci_mscanf.Tpo -c -o libscifileio_la-sci_mscanf.lo `test -f 'sci_gateway/cpp/sci_mscanf.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_mscanf.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscifileio_la-sci_mscanf.Tpo $(DEPDIR)/libscifileio_la-sci_mscanf.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_mscanf.cpp' object='libscifileio_la-sci_mscanf.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscifileio_la-sci_mscanf.lo `test -f 'sci_gateway/cpp/sci_mscanf.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_mscanf.cpp
+
+libscifileio_la-sci_msscanf.lo: sci_gateway/cpp/sci_msscanf.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscifileio_la-sci_msscanf.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-sci_msscanf.Tpo -c -o libscifileio_la-sci_msscanf.lo `test -f 'sci_gateway/cpp/sci_msscanf.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_msscanf.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscifileio_la-sci_msscanf.Tpo $(DEPDIR)/libscifileio_la-sci_msscanf.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_msscanf.cpp' object='libscifileio_la-sci_msscanf.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscifileio_la-sci_msscanf.lo `test -f 'sci_gateway/cpp/sci_msscanf.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_msscanf.cpp
+
 mostlyclean-libtool:
        -rm -f *.lo
 
index 9856124..61bcc4a 100644 (file)
@@ -250,6 +250,7 @@ lib /DEF:"$(ProjectDir)System_env_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:X64 /O
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClCompile Include="src\cpp\scilab_sscanf.cpp" />
     <ClCompile Include="src\c\addfile.c" />
     <ClCompile Include="src\c\basename.c" />
     <ClCompile Include="src\c\cluni0.c" />
@@ -308,11 +309,7 @@ lib /DEF:"$(ProjectDir)System_env_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:X64 /O
     <ClCompile Include="sci_gateway\c\sci_getlongpathname.c" />
     <ClCompile Include="sci_gateway\c\sci_getrelativefilename.c" />
     <ClCompile Include="sci_gateway\c\sci_maxfiles.c" />
-    <ClCompile Include="sci_gateway\c\sci_mfprintf.c" />
-    <ClCompile Include="sci_gateway\c\sci_mfscanf.c" />
     <ClCompile Include="sci_gateway\c\sci_movefile.c" />
-    <ClCompile Include="sci_gateway\c\sci_mscanf.c" />
-    <ClCompile Include="sci_gateway\c\sci_msscanf.c" />
     <ClCompile Include="sci_gateway\c\sci_newest.c" />
     <ClCompile Include="sci_gateway\c\sci_pwd.c" />
     <ClCompile Include="src\c\scicurdir.c" />
@@ -350,6 +347,9 @@ lib /DEF:"$(ProjectDir)System_env_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:X64 /O
       <Project>{3170e4c2-1173-4264-a222-7ee8ccb3ddf7}</Project>
       <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
     </ProjectReference>
+    <ProjectReference Include="..\abstractSyntaxTree\abstractSyntaxTree-tools.vcxproj">
+      <Project>{1f4a0344-99ed-461b-bd53-1593788fb34d}</Project>
+    </ProjectReference>
     <ProjectReference Include="..\api_scilab\api_scilab.vcxproj">
       <Project>{43c5bab1-1dca-4743-a183-77e0d42fe7d0}</Project>
       <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
@@ -381,6 +381,7 @@ lib /DEF:"$(ProjectDir)System_env_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:X64 /O
     <ClInclude Include="includes\createdirectory.h" />
     <ClInclude Include="includes\deleteafile.h" />
     <ClInclude Include="includes\delfile.h" />
+    <ClInclude Include="includes\do_xxscanf.h" />
     <ClInclude Include="includes\dynlib_fileio.h" />
     <ClInclude Include="includes\expandPathVariable.h" />
     <ClInclude Include="includes\FileExist.h" />
@@ -407,9 +408,11 @@ lib /DEF:"$(ProjectDir)System_env_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:X64 /O
     <ClInclude Include="includes\os_wfopen.h" />
     <ClInclude Include="includes\readline.h" />
     <ClInclude Include="includes\removedir.h" />
+    <ClInclude Include="includes\scanf_functions.h" />
     <ClInclude Include="includes\scicurdir.h" />
     <ClInclude Include="includes\splitpath.h" />
     <ClInclude Include="includes\URIFileToFilename.h" />
+    <ClInclude Include="src\cpp\scilab_sscanf.hxx" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
index 7f04b74..8e01234 100644 (file)
     <ClCompile Include="sci_gateway\c\sci_maxfiles.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="sci_gateway\c\sci_mfprintf.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="sci_gateway\c\sci_mfscanf.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="sci_gateway\c\sci_movefile.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="sci_gateway\c\sci_mscanf.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="sci_gateway\c\sci_msscanf.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="sci_gateway\c\sci_newest.c">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="src\c\URIFileToFilename.c">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="src\cpp\scilab_sscanf.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="src\c\fileio.rc">
     <ClInclude Include="includes\URIFileToFilename.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="src\cpp\scilab_sscanf.hxx">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="includes\do_xxscanf.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="includes\scanf_functions.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
 </Project>
\ No newline at end of file
similarity index 83%
rename from scilab/modules/fileio/src/c/do_xxscanf.h
rename to scilab/modules/fileio/includes/do_xxscanf.h
index 6292dc5..f61358c 100644 (file)
@@ -14,6 +14,7 @@
 #define __DO_XXSCANF_H__
 
 #include <stdio.h>
+#include "dynlib_fileio.h"
 
 /*if maxscan is increased don't forget to change the (*xxscanf)(......) 
 in do_xxscanf procedure */
@@ -22,7 +23,7 @@ in do_xxscanf procedure */
 
 typedef union 
 {
-       char * c;
+       wchar_t * c;
        long unsigned int lui;
        short unsigned int sui;
        unsigned int ui;
@@ -36,10 +37,10 @@ typedef union
 typedef union 
 {
        double d;
-       char * s;
+       wchar_t * s;
 } entry;
 typedef enum {SF_C,SF_S,SF_LUI,SF_SUI,SF_UI,SF_LI,SF_SI,SF_I,SF_LF,SF_F} sfdir;
 
-int do_xxscanf (char *fname, FILE *fp, char *format, int *nargs, char *strv, int *retval, rec_entry *buf, sfdir *type);
+FILEIO_IMPEXP int do_xxscanf (wchar_t *fname, FILE *fp, wchar_t *format, int *nargs, wchar_t *strv, int *retval, rec_entry *buf, sfdir *type);
 #endif /* __DO_XXSCANF_H__ */
 
index 19e12a1..71635fe 100644 (file)
@@ -68,6 +68,9 @@ CPP_GATEWAY_PROTOTYPE(sci_mclearerr);
 CPP_GATEWAY_PROTOTYPE(sci_get_absolute_file_path);
 CPP_GATEWAY_PROTOTYPE(sci_getrelativefilename);
 CPP_GATEWAY_PROTOTYPE(sci_pathsep);
-
+CPP_GATEWAY_PROTOTYPE(sci_mfprintf);
+CPP_GATEWAY_PROTOTYPE(sci_mscanf);
+CPP_GATEWAY_PROTOTYPE(sci_mfscanf);
+CPP_GATEWAY_PROTOTYPE(sci_msscanf);
 
 #endif /* !__FILEIO_GW_HXX__ */
index 4f94cbe..7439989 100644 (file)
 FILEIO_IMPEXP int gw_fileio(void);
 /*--------------------------------------------------------------------------*/
 
-FILEIO_IMPEXP int sci_mfprintf(char *fname,unsigned long fname_len);
-FILEIO_IMPEXP int sci_scanf(char *fname,unsigned long fname_len);
-FILEIO_IMPEXP int sci_sscanf(char *fname,unsigned long fname_len);
-FILEIO_IMPEXP int sci_fscanf(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_maxfiles(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_getdrives(char *fname,unsigned long fname_len);
 
 #define __SCAN_FUNCTIONS_H__
 
 #include "do_xxscanf.h"
-
+#include "dynlib_fileio.h"
 /**
 * @TODO add comments
 */
-void Free_Scan (int rowcount,
+FILEIO_IMPEXP void Free_Scan (int rowcount,
                                int ncol,
                                sfdir *type_s,
                                entry **data);
@@ -27,16 +27,7 @@ void Free_Scan (int rowcount,
 /**
 * @TODO add comments
 */
-int Sci_Store (int nrow,
-                          int ncol,
-                          entry* data,
-                          sfdir *type,
-                          int retval);
-
-/**
-* @TODO add comments
-*/
-int Store_Scan (int *nrow,
+FILEIO_IMPEXP int Store_Scan (int *nrow,
                                int *ncol,
                                sfdir *type_s,
                                sfdir *type,
index d5e7c3c..3acd74f 100644 (file)
@@ -29,12 +29,12 @@ static gw_generic_table Tab[]={
        {NULL, ""}, //mseek
        {NULL, ""}, //mtell
        {NULL, ""}, //mclearerr
-       {sci_mfprintf,"mfprintf"}, //
-       {sci_scanf,"mscanf"}, //
-       {sci_fscanf,"mfscanf"}, //
-       {sci_sscanf,"msscanf"}, //
-       {sci_fscanfMat,"fscanfMat"},
-       {sci_fprintfMat,"fprintfMat"},
+       {NULL, ""}, //mfprintf *
+       {NULL, ""}, //mscanf *
+       {NULL, ""}, //mfscanf *
+       {NULL, ""}, //msscanf *
+       {NULL,""}, //fscanfMat
+       {NULL,""}, //fprintfMat
        {NULL, ""}, //merror
        {NULL, ""}, //findfiles
        {sci_maxfiles,"maxfiles"},
diff --git a/scilab/modules/fileio/sci_gateway/c/sci_mfprintf.c b/scilab/modules/fileio/sci_gateway/c/sci_mfprintf.c
deleted file mode 100644 (file)
index bd965a8..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) INRIA
- * ...
- * 
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution.  The terms
- * are also available at    
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-#include "Scierror.h"
-#include "stack-c.h"
-#include "do_xxprintf.h"
-#include "gw_fileio.h"
-#include "filesmanagement.h"
-#include "localization.h"
-#include "BOOL.h"
-#include "sci_mode.h"
-/*--------------------------------------------------------------------------*/ 
-#ifdef _MSC_VER
-static BOOL forceSTDERRredirect = TRUE;
-#endif
-/*--------------------------------------------------------------------------*/ 
-int sci_mfprintf(char *fname,unsigned long fname_len)
-{
-       FILE *f;
-       BOOL isSTD = FALSE;
-       int fileMode = 0;
-       int l1 = 0, m1 = 0, n1 = 0;
-       int l2 = 0,m2 = 0,n2 = 0;
-       int lcount = 0,rval = 0, mx = 0, mk = 0, nk = 0, k = 0;
-       char *ptrFormat = NULL;
-       int i = 0;
-       int NumberPercent = 0;
-       int param1 = 0;
-
-       Nbvars = 0;
-       CheckRhs(1, 1000);
-       CheckLhs(0, 1);
-       if ( Rhs < 2 ) 
-       { 
-               Scierror(999, _("%s: Wrong number of input arguments: At least %d expected.\n"),fname,2);
-               return 0;
-       }
-       for ( k = 3; k <= Rhs; k++) 
-       {
-               if (VarType(k) !=sci_matrix && VarType(k) !=sci_strings) 
-               {
-                       OverLoad(k);
-                       return 0;
-               }
-       }
-       GetRhsVar(1, MATRIX_OF_INTEGER_DATATYPE, &m1, &n1, &l1); /* file id */
-       GetRhsVar(2, STRING_DATATYPE, &m2, &n2, &l2); /* format */
-       ptrFormat = cstk(l2);
-
-       param1 = *istk(l1);
-
-       switch (param1)
-       {
-       case 0:
-               #ifdef _MSC_VER
-               if ( (getScilabMode()  == SCILAB_STD) && (forceSTDERRredirect == TRUE) )
-               {
-                       /*  Console redirect stderr --> CONOUT$*/
-                       freopen("CONOUT$", "wb", stderr); 
-                       forceSTDERRredirect = FALSE;
-               }
-               #endif
-               f = stderr;
-               break;
-       case 5:
-               // stdin; 
-               f = (FILE *)0;
-               break;
-       case 6:
-               f = stdout;
-               break;
-       default:
-               f = GetFileOpenedInScilab(param1);
-               break;
-       }
-
-       if (f == (FILE *)0 )
-       {
-               Scierror(999,_("%s: Wrong file descriptor: %d.\n"),fname,*istk(l1));
-               return 0;
-       }
-
-       switch (param1)
-       {
-       case 0: case 6:
-               isSTD = TRUE;
-               break;
-       default:
-               isSTD = FALSE;
-               fileMode = GetFileModeOpenedInScilab(param1);
-               break;
-       }
-
-       
-       /* checks file mode */
-       /* bug 3898 */
-       /* read only attrib 1xx*/
-       if ( (fileMode >= 100) && (fileMode < 200) && !isSTD)
-       {
-               Scierror(999,_("%s: Wrong file mode: READ only.\n"),fname);
-               return 0;
-       }
-
-       for(i = 0; i < (int)strlen(ptrFormat); i++)
-       {
-               if (ptrFormat[i] == '%') 
-               {
-                       NumberPercent++;
-                       if (ptrFormat[i+1] == '%') 
-                       {
-                               NumberPercent--;
-                               i++;
-                       }
-               }
-       }
-
-       if (NumberPercent < Rhs-2)
-       {
-               Scierror(999,_("%s: Wrong number of input arguments: %d expected.\n"),fname,NumberPercent+2);
-               return 0;
-       }
-
-       mx = 0;
-       if (Rhs >= 3) 
-       {
-               GetMatrixdims(3, &mx, &nk);
-               for (k = 4; k <= Rhs; k++) 
-               {
-                       GetMatrixdims(k, &mk, &nk);
-                       mx = Min(mx, mk);
-               }
-       }
-       lcount = 1;
-       if (Rhs == 2) 
-       {
-               rval = do_xxprintf("fprintf", f, cstk(l2), Rhs, 2, lcount, (char **)0);
-       }
-       else while (1) 
-       {
-               if ((rval = do_xxprintf("fprintf", f, cstk(l2), Rhs, 2, lcount, (char **)0)) < 0) break;
-               lcount++;
-               if (lcount > mx) break;
-       }
-       if (rval == DO_XXPRINTF_RET_BUG) return 0;
-       LhsVar(1) = 0; /** No return value **/
-       PutLhsVar();
-       return 0;
-} 
-/*--------------------------------------------------------------------------*/ 
diff --git a/scilab/modules/fileio/sci_gateway/c/sci_mfscanf.c b/scilab/modules/fileio/sci_gateway/c/sci_mfscanf.c
deleted file mode 100644 (file)
index 8df86b8..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) INRIA
- * ...
- * 
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution.  The terms
- * are also available at    
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-#include <stdio.h>
-#include "stack-c.h"
-#include "do_xxprintf.h"
-#include "do_xxscanf.h"
-#include "scanf_functions.h"
-#include "StringConvert.h"
-#include "gw_fileio.h"
-#include "filesmanagement.h"
-#include "Scierror.h"
-#include "localization.h"
-/*--------------------------------------------------------------------------*/
-int sci_fscanf(char *fname,unsigned long fname_len)
-{
-       static int l1, m1, n1,l2,m2,n2,iarg,maxrow,nrow,rowcount,ncol;
-       FILE  *f;
-       int args,retval,err;
-       int retval_s=0;
-       entry *data=NULL;
-       long int pos;
-       int param1=0;
-
-       rec_entry buf[MAXSCAN];
-       sfdir  type[MAXSCAN],type_s[MAXSCAN];
-
-       Nbvars = 0;
-       CheckRhs(2,3);
-
-       if (Rhs==3)
-       {
-               GetRhsVar(1,MATRIX_OF_INTEGER_DATATYPE,&m1,&n1,&l1);
-               if (m1*n1 != 1 )
-               {
-                       Scierror(999,_("%s: Wrong size for input argument #%d: Scalar expected.\n"),fname,1);
-                       return 0;
-               }
-               iarg=2;
-               maxrow=*istk(l1);
-       }
-       else
-       {
-               iarg=1;
-               maxrow=1;
-       }
-
-       GetRhsVar(iarg,MATRIX_OF_INTEGER_DATATYPE,&m1,&n1,&l1);
-       GetRhsVar(iarg+1,STRING_DATATYPE,&m2,&n2,&l2);/* format */
-
-       param1 = *istk(l1);
-       StringConvert(cstk(l2));  /* conversion */
-
-       switch (param1)
-       {
-       case 0:
-               // stderr
-               f = (FILE *)0;
-               break;
-       case 5:
-               f = stdin;
-               break;
-       case 6:
-               // stdout
-               f = (FILE *)0;
-               break;
-       default:
-               f = GetFileOpenedInScilab(param1);
-               break;
-       }
-
-       if (f == (FILE *)0)
-       {
-               Scierror(999,_("%s: Wrong file descriptor: %d.\n"),fname,param1);
-               return 0;
-       }
-
-       nrow = maxrow;
-       rowcount = -1;
-
-       while (1)
-       {
-               rowcount++;
-               if ((maxrow >= 0) && (rowcount >= maxrow)) break;
-               args = Rhs; /* args set to Rhs on entry */
-               pos=ftell(f);
-               if ( do_xxscanf("fscanf",f,cstk(l2),&args,(char *)0,&retval,buf,type) < 0 )  return 0;
-               if ( retval == EOF)
-               {
-                       /*
-                       Scierror(999,"Error: in %s: end of file reached\n",fname);
-                       */
-                       break;
-               }
-               if ((err=Store_Scan(&nrow,&ncol,type_s,type,&retval,&retval_s,buf,&data,rowcount,args)) <0 )
-               {
-                       switch (err)
-                       {
-                       case DO_XXPRINTF_MISMATCH:
-                               if (maxrow>=0)
-                               {
-                                       Free_Scan(rowcount,ncol,type_s,&data);
-                                       Scierror(999,_("%s: Data mismatch.\n"),fname);
-                                       return 0;
-                               }
-                               fseek(f,pos,SEEK_SET);
-                               break;
-
-                       case DO_XXPRINTF_MEM_LACK:
-                               Free_Scan(rowcount,ncol,type_s,&data);
-                               Scierror(999,_("%s: No more memory.\n"),fname);
-                               return 0;
-                               break;
-                       }
-                       if (err==DO_XXPRINTF_MISMATCH) break;
-               }
-       } /* while */
-
-       /* create Scilab variable with each column of data */
-       err=Sci_Store(rowcount,ncol,data,type_s,retval_s);
-       Free_Scan(rowcount,ncol,type_s,&data);
-       if (err==DO_XXPRINTF_MEM_LACK) { Scierror(999,_("%s: No more memory.\n"),fname);}
-       return 0;
-}
-/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/fileio/sci_gateway/c/sci_mscanf.c b/scilab/modules/fileio/sci_gateway/c/sci_mscanf.c
deleted file mode 100644 (file)
index b4da004..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) INRIA
- * Copyright (C) DIGITEO - 2010 - Allan CORNET
- *
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution.  The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-#include <string.h>
-#include "Scierror.h"
-#include "MALLOC.h"
-#include "stack-c.h"
-#include "do_xxscanf.h"
-#include "do_xxprintf.h"
-#include "gw_fileio.h"
-#include "localization.h"
-#include "scanf_functions.h"
-#include "StringConvert.h"
-#include "xscion.h"
-#include "../../../shell/includes/zzledt.h"
-#include "../../../shell/includes/GetCommandLine.h" /* getConsoleInputLine */
-#include "os_strdup.h"
-/*--------------------------------------------------------------------------*/
-#define MAXSTR 512
-/*--------------------------------------------------------------------------*/
-int sci_scanf(char *fname,unsigned long fname_len)
-{
-    static char *String = NULL;
-    static int l1 = 0, m1 = 0, n1 = 0, len = MAXSTR-1,iarg  = 0,maxrow = 0,nrow = 0,rowcount = 0,ncol = 0;
-    int args = 0,retval = 0,retval_s = 0,lline = 0,status = 0,iflag = 0,err = 0,n_count = 0;
-    int interrupt = 0;
-    entry *data = NULL;
-    rec_entry buf[MAXSCAN];
-    sfdir  type[MAXSCAN],type_s[MAXSCAN];
-
-    Nbvars = 0;
-    CheckRhs(1,2);
-
-    if (Rhs==2)
-    {
-        GetRhsVar(1,MATRIX_OF_INTEGER_DATATYPE,&m1,&n1,&l1);
-        if (m1*n1 != 1)
-        {
-            Scierror(999,_("%s: Wrong size for input argument #%d: Scalar expected.\n"),fname,1);
-            return 0;
-        }
-        iarg=2;
-        maxrow=*istk(l1);
-    }
-    else
-    {
-        iarg=1;
-        maxrow=1;
-    }
-
-    GetRhsVar(iarg,STRING_DATATYPE,&m1,&n1,&l1); /** format **/
-    n_count=StringConvert(cstk(l1))+1;  /* conversion */
-
-    if (n_count>1)
-    {
-        Scierror(999,_("%s: Specified format cannot include any '\\n'\n"),fname);
-        return 0;
-    }
-
-    nrow=maxrow;
-    rowcount = -1; /* number-1 of result lines already got */
-    while (1)
-    {
-        rowcount++;
-        if ((maxrow >= 0) && (rowcount >= maxrow)) break;
-
-        /* get a line */
-        C2F(xscion)(&iflag);
-        //C2F(zzledt)(String,&len,&lline,&status,&interrupt,&iflag,(long int)strlen(String));
-        //getLine(String,&len,&lline,&status);
-        String = getConsoleInputLine();
-        if (String == NULL)
-        {
-            Scierror(999,_("%s: Data mismatch.\n"),fname);
-            return 0;
-        }
-        lline = (int)strlen(String);
-
-        if (lline == 0)
-        {
-            FREE(String);
-            String = os_strdup(" ");
-            lline = (int)strlen(String);
-        }
-
-        /** use the scaned line as input **/
-        args = Rhs; /* args set to Rhs on entry */
-        if (do_xxscanf("scanf",(FILE *) 0,cstk(l1),&args,String,&retval,buf,type) < 0)
-        {
-            if (String) {FREE(String); String = NULL;}
-            return 0;
-        }
-        if (String) {FREE(String); String = NULL;}
-
-        if ((err=Store_Scan(&nrow,&ncol,type_s,type,&retval,&retval_s,buf,&data,rowcount,args)) <0 )
-        {
-            switch (err)
-            {
-            case DO_XXPRINTF_MISMATCH:
-                if (maxrow>=0)
-                {
-                    Free_Scan(rowcount,ncol,type_s,&data);
-                    Scierror(999,_("%s: Data mismatch.\n"),fname);
-                    return 0;
-                }
-                break;
-
-            case DO_XXPRINTF_MEM_LACK:
-                Free_Scan(rowcount,ncol,type_s,&data);
-                Scierror(999,_("%s: No more memory.\n"),fname);
-                return 0;
-                break;
-            }
-        }
-    } /*  while (1) */
-
-    /* create Scilab variables with each column of data */
-    err=Sci_Store(rowcount,ncol,data,type_s,retval_s);
-    Free_Scan(rowcount,ncol,type_s,&data);
-    if (err==DO_XXPRINTF_MEM_LACK) { Scierror(999,_("%s: No more memory.\n"),fname);}
-    return 0;
-}
-/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/fileio/sci_gateway/c/sci_msscanf.c b/scilab/modules/fileio/sci_gateway/c/sci_msscanf.c
deleted file mode 100644 (file)
index a654f8c..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) INRIA
- * ...
- * 
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution.  The terms
- * are also available at    
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-#include <stdio.h>
-#include "MALLOC.h"
-#include "stack-c.h"
-#include "do_xxprintf.h"
-#include "do_xxscanf.h"
-#include "scanf_functions.h"
-#include "scistrtostr.h"
-#include "StringConvert.h"
-#include "gw_fileio.h"
-#include "Scierror.h"
-#include "localization.h"
-
-/*--------------------------------------------------------------------------*/
-int sci_sscanf(char *fname,unsigned long fname_len)
-{
-       static int l1, m1, n1,l2,m2,n2,iarg,maxrow,nrow,rowcount,ncol;
-       int args,retval,retval_s,err,n_count,lw,il1,ild1,skip;
-       int k;
-
-       entry *data;
-       rec_entry buf[MAXSCAN];
-       sfdir  type[MAXSCAN],type_s[MAXSCAN];
-       char* str;
-
-       Nbvars = 0;
-       CheckRhs(2,3);
-
-       if (Rhs==3)
-       {
-               GetRhsVar(1,MATRIX_OF_INTEGER_DATATYPE,&m1,&n1,&l1);
-               if (m1*n1!=1)
-               {
-                       Scierror(999,_("%s: Wrong size for input argument #%d: Scalar expected.\n"),fname,1);
-                       return 0;
-               }
-
-               iarg=2;
-               maxrow=*istk(l1);
-       }
-       else
-       {
-               iarg=1;
-               maxrow=1;
-       }
-
-       lw = iarg + Top - Rhs; /* Scilab string vector */
-       if (! C2F(getwsmat)("sscanf",&Top,&lw,&m1,&n1,&il1,&ild1,6L)) return 0;
-       GetRhsVar(iarg+1,STRING_DATATYPE,&m2,&n2,&l2); /* Format */
-       n_count=StringConvert(cstk(l2))+1;  /* conversion */
-
-       if ( (maxrow >= 0) && (maxrow*n_count>m1*n1) )
-       {
-               Scierror(999,_("%s: An error occurred: %s\n"),fname,_("Not enough entries."));
-               return 0;
-       }
-
-       k=0;
-       nrow=maxrow;
-       rowcount = -1; /* number-1 of result lines already got */
-       while (1)
-       {
-               rowcount++;
-               if ((maxrow >= 0) && (rowcount >= maxrow)) break;
-               if ( k >= m1*n1 ) break;
-               skip=*istk(ild1+k)-1;
-               SciStrtoStr(istk(il1+skip),&n_count,istk(ild1+k),&str);
-               k +=n_count;
-
-               args = Rhs; /* args set to Rhs on entry */
-               err = do_xxscanf("sscanf",(FILE *)0,cstk(l2),&args,str,&retval,buf,type);
-               FREE(str);
-               if ( err < 0 )  return 0;
-
-               if ((err=Store_Scan(&nrow,&ncol,type_s,type,&retval,&retval_s,buf,&data,rowcount,args)) <0 )
-               {
-                       switch (err)
-                       {
-                       case DO_XXPRINTF_MISMATCH:
-                               if (maxrow>=0)
-                               {
-                                       Free_Scan(rowcount,ncol,type_s,&data);
-                                       Scierror(999,_("%s: Data mismatch.\n"),fname);
-                                       return 0;
-                               }
-                               break;
-
-                       case DO_XXPRINTF_MEM_LACK:
-                               Free_Scan(rowcount,ncol,type_s,&data);
-                               Scierror(999,_("%s: No more memory.\n"),fname);
-                               return 0;
-                               break;
-                       }
-
-                       if (err==DO_XXPRINTF_MISMATCH) break;
-               }
-       } /* while */
-
-       /* create Scilab variables with each column of data */
-       err=Sci_Store(rowcount,ncol,data,type_s,retval_s);
-       Free_Scan(rowcount,ncol,type_s,&data);
-       if (err==DO_XXPRINTF_MEM_LACK) { Scierror(999,_("%s: No more memory.\n"),fname);}
-       return 0;
-}
-/*--------------------------------------------------------------------------*/
index bd88886..0c691b7 100644 (file)
@@ -59,6 +59,11 @@ bool FileioModule::Load()
     symbol::Context::getInstance()->AddFunction(Function::createFunction(L"get_absolute_file_path", &sci_get_absolute_file_path, MODULE_NAME));
     symbol::Context::getInstance()->AddFunction(Function::createFunction(L"getrelativefilename", &sci_getrelativefilename, MODULE_NAME));
     symbol::Context::getInstance()->AddFunction(Function::createFunction(L"pathsep", &sci_pathsep, MODULE_NAME));
+    symbol::Context::getInstance()->AddFunction(Function::createFunction(L"mfprintf", &sci_mfprintf, MODULE_NAME));
+    symbol::Context::getInstance()->AddFunction(Function::createFunction(L"mscanf", &sci_mscanf, MODULE_NAME));   
+    symbol::Context::getInstance()->AddFunction(Function::createFunction(L"mfscanf", &sci_mfscanf, MODULE_NAME));
+    symbol::Context::getInstance()->AddFunction(Function::createFunction(L"msscanf", &sci_msscanf, MODULE_NAME));
 
     return true;
 }
+
index 3213f5d..6139585 100644 (file)
     <ClCompile Include="sci_mclose.cpp" />
     <ClCompile Include="sci_meof.cpp" />
     <ClCompile Include="sci_merror.cpp" />
+    <ClCompile Include="sci_mfprintf.cpp" />
+    <ClCompile Include="sci_mfscanf.cpp" />
     <ClCompile Include="sci_mget.cpp" />
     <ClCompile Include="sci_mgetl.cpp" />
     <ClCompile Include="sci_mgetstr.cpp" />
     <ClCompile Include="sci_mput.cpp" />
     <ClCompile Include="sci_mputl.cpp" />
     <ClCompile Include="sci_mputstr.cpp" />
+    <ClCompile Include="sci_mscanf.cpp" />
     <ClCompile Include="sci_mseek.cpp" />
+    <ClCompile Include="sci_msscanf.cpp" />
     <ClCompile Include="sci_mtell.cpp" />
     <ClCompile Include="sci_newest.cpp" />
     <ClCompile Include="sci_pathconvert.cpp" />
     <ProjectReference Include="..\..\..\abstractSyntaxTree\abstractSyntaxTree-tools.vcxproj">
       <Project>{1f4a0344-99ed-461b-bd53-1593788fb34d}</Project>
     </ProjectReference>
+    <ProjectReference Include="..\..\..\abstractSyntaxTree\abstractSyntaxTree.vcxproj">
+      <Project>{0d3fa25b-8116-44ec-a45e-260789daa3d9}</Project>
+    </ProjectReference>
     <ProjectReference Include="..\..\..\api_scilab\api_scilab.vcxproj">
       <Project>{43c5bab1-1dca-4743-a183-77e0d42fe7d0}</Project>
       <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
       <Project>{1bb396f7-ce61-4cfc-9c22-266b2cfb2e74}</Project>
       <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
     </ProjectReference>
+    <ProjectReference Include="..\..\..\output_stream\sci_gateway\cpp\output_stream_gw\output_stream_gw.vcxproj">
+      <Project>{c000fdf7-4d32-4630-9595-560d9cc66d11}</Project>
+    </ProjectReference>
     <ProjectReference Include="..\..\..\output_stream\src\c\output_stream.vcxproj">
       <Project>{a5911cd7-f8e8-440c-a23e-4843a0636f3a}</Project>
-      <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
     </ProjectReference>
     <ProjectReference Include="..\..\..\symbol\symbol.vcxproj">
       <Project>{2c60033b-0dbd-4ca4-80d3-176c9be9ce2f}</Project>
index 9801012..38290f2 100644 (file)
     <ClCompile Include="sci_removedir.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="sci_mfprintf.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_mfscanf.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_mscanf.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_msscanf.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\includes\fileio_gw.hxx">
index e555986..6288c23 100644 (file)
@@ -79,5 +79,7 @@ Function::ReturnValue sci_get_absolute_file_path(types::typed_list &in, int _iRe
         ScierrorW(999,_W("%ls: The file %ls is not opened in scilab.\n"), L"get_absolute_file_path", wcsFileName);
         return types::Function::Error;
     }
+
+    return types::Function::OK;
 }
 /*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/fileio/sci_gateway/cpp/sci_mfprintf.cpp b/scilab/modules/fileio/sci_gateway/cpp/sci_mfprintf.cpp
new file mode 100644 (file)
index 0000000..5d50ccc
--- /dev/null
@@ -0,0 +1,218 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2006 - INRIA - Allan CORNET
+* Copyright (C) 2009 - DIGITEO - Allan CORNET
+* Copyright (C) 2010 - DIGITEO - Antoine ELIAS
+* Copyright (C) 2011 - DIGITEO - 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
+*
+*/
+/*--------------------------------------------------------------------------*/
+#include "funcmanager.hxx"
+#include "filemanager.hxx"
+#include "fileio_gw.hxx"
+#include "function.hxx"
+#include "string.hxx"
+#include "scilab_sprintf.hxx"
+#include "overload.hxx"
+#include "execvisitor.hxx"
+
+extern "C"
+{
+#include <stdio.h>
+#include "localization.h"
+#include "Scierror.h"
+#include "MALLOC.h"
+#include "sci_mode.h"
+#include "mputl.h"
+}
+/*--------------------------------------------------------------------------*/ 
+#ifdef _MSC_VER
+static BOOL forceSTDERRredirect = TRUE;
+#endif
+/*--------------------------------------------------------------------------*/ 
+
+Function::ReturnValue sci_mfprintf(types::typed_list &in, int _iRetCount, types::typed_list &out)
+{
+    BOOL isSTD                      = FALSE;
+    BOOL isSTDErr                   = FALSE;
+    int iFile                       = -1; //default file : last opened file
+    int iRet                        = 1;  // push not iRet
+    unsigned int iNumberPercent     = 0;
+    unsigned int iNumberCols        = 0;
+    int nbrOfLines                  = 0;
+    double dfileMode                = 0;
+    wchar_t* wcsInput               = NULL;
+    wchar_t** wcsStringToWrite      = NULL;
+    ArgumentPosition* pArgs         = NULL;
+
+    if(in.size() < 2)
+    {
+       ScierrorW(77, _W("%ls: Wrong number of input argument(s): At least %d expected.\n"), L"mfprintf", 2);
+        return types::Function::Error;
+    }
+
+    if(in[0]->isDouble() == false || in[0]->getAs<types::Double>()->isScalar() == false || in[0]->getAs<types::Double>()->isComplex())
+    {
+        ScierrorW(999, _W("%ls: Wrong type for input argument #%d: A Real expected.\n"), L"mfprintf", 1);
+        return types::Function::Error;
+    }
+
+    if(in[1]->isString() == false || in[1]->getAs<types::String>()->isScalar() == false)
+    {
+        ScierrorW(999, _W("%ls: Wrong type for input argument #%d: A String expected.\n"), L"mfprintf", 2);
+        return types::Function::Error;
+    }
+
+    for(unsigned int i = 2 ; i < in.size() ; i++)
+    {
+        if(in[i]->isDouble() == false && in[i]->isString() == false)
+        {
+            std::wstring wstFuncName = L"%"  + in[i]->getShortTypeStr() + L"_mfprintf";
+            return Overload::call(wstFuncName, in, _iRetCount, out, new ExecVisitor());
+        }
+    }
+
+// checking ID of file
+    iFile = static_cast<int>(in[0]->getAs<types::Double>()->getReal()[0]);
+
+       if(FileManager::getFile(iFile) == NULL)
+       {           
+        ScierrorW(999, _W("%ls: Wrong file descriptor: %d.\n"), L"mfprintf", iFile);
+        return types::Function::Error;
+       }
+
+    switch (iFile)
+    {
+    case 0:
+        #ifdef _MSC_VER
+        if((getScilabMode()  == SCILAB_STD) && (forceSTDERRredirect == TRUE))
+        {
+        //  Console redirect stderr --> CONOUT$
+        freopen("CONOUT$", "wb", stderr); 
+        forceSTDERRredirect = FALSE;
+        }
+        #endif
+        isSTDErr = TRUE;
+    case 6:
+        isSTD = TRUE;
+        break;
+    case 5:
+        ScierrorW(999, _W("%ls: Wrong file descriptor: %d.\n"), L"mfprintf", iFile);
+        return types::Function::Error;
+    default:
+        isSTD = FALSE;
+        dfileMode = FileManager::getFile(iFile)->getFileModeAsDouble();
+        break;
+    }
+    
+    /* checks file mode */
+    /* bug 3898 */
+    /* read only attrib 1xx*/
+    if((dfileMode >= 100) && (dfileMode < 200) && !isSTD)
+    {
+        ScierrorW(999, _W("%ls: Wrong file mode: READ only.\n"), L"mfprintf");
+        return types::Function::Error;
+    }
+
+// Checking input string to write in file
+    wcsInput = in[1]->getAs<types::String>()->get(0);
+
+    for(int i = 0; i < (int)wcslen(wcsInput); i++)
+    {
+        if (wcsInput[i] == '%') 
+        {
+            iNumberPercent++;
+            if (wcsInput[i+1] == '%') 
+            {
+                iNumberPercent--;
+                i++;
+            }
+        }
+    }
+
+    //Input values must be less or equal than excepted
+    if((in.size() - 2) > iNumberPercent)
+    {
+        ScierrorW(999, _W("%ls: Wrong number of input arguments: at most %d expected.\n"), L"mprintf", iNumberPercent);
+        return types::Function::Error;
+    }
+
+    //determine if imput values are ... multiple values
+
+    if( in.size() > 2 )
+    {
+        int iRefRows = in[2]->getAsGenericType()->getRows();
+        for(unsigned int i = 2 ; i < in.size() ; i++)
+        {
+            //all arguments must have the same numbers of rows !
+            if(iRefRows != in[i]->getAsGenericType()->getRows())
+            {
+                ScierrorW(999, _W("%ls: Wrong number of input arguments: data doesn't fit with format.\n"), L"mprintf");
+                return types::Function::Error;
+            }
+
+            iNumberCols += in[i]->getAsGenericType()->getCols();
+        }
+    }
+
+    if(iNumberCols != iNumberPercent)
+    {
+        ScierrorW(999, _W("%ls: Wrong number of input arguments: data doesn't fit with format.\n"), L"mprintf");
+        return types::Function::Error;
+    }  
+
+    //fill ArgumentPosition structure
+    pArgs = new ArgumentPosition[iNumberPercent];
+    int idx = 0;
+    for(unsigned int i = 2 ; i < in.size() ; i++)
+    {
+        for(int j = 0 ; j < in[i]->getAsGenericType()->getCols() ; j++)
+        {
+            pArgs[idx].iArg = i;
+            pArgs[idx].iPos = j;
+            pArgs[idx].type = in[i]->getType();
+            idx++;
+        }
+    }
+
+    wcsStringToWrite = scilab_sprintf(L"mfprintf", wcsInput, in, pArgs, iNumberPercent, &nbrOfLines);
+
+    if(isSTD)
+    {
+        for(int i=0; i<nbrOfLines; i++)
+        {
+            if(isSTDErr)
+            {
+                std::wcerr << wcsStringToWrite[i];
+            }
+            else
+            {
+                YaspWriteW(wcsStringToWrite[i]);
+            }
+        }
+        std::cout << "\n";
+        iRet = 0;
+    }
+    else
+    {
+        iRet = mputl(iFile, wcsStringToWrite, nbrOfLines, FALSE); // FALSE = don't add the "\n" at the end.
+    }
+
+    for(int i=0; i<nbrOfLines; i++)
+    {
+        FREE(wcsStringToWrite[i]);
+    }
+
+    FREE(wcsStringToWrite);
+    FREE(pArgs);
+
+    out.push_back(new Bool(!iRet));
+    return types::Function::OK;
+}
+/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/fileio/sci_gateway/cpp/sci_mfscanf.cpp b/scilab/modules/fileio/sci_gateway/cpp/sci_mfscanf.cpp
new file mode 100644 (file)
index 0000000..bc6861e
--- /dev/null
@@ -0,0 +1,313 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2006 - INRIA - Allan CORNET
+* Copyright (C) 2009 - DIGITEO - Allan CORNET
+* Copyright (C) 2010 - DIGITEO - Antoine ELIAS
+* Copyright (C) 2011 - DIGITEO - 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
+*
+*/
+/*--------------------------------------------------------------------------*/
+#include "fileio_gw.hxx"
+#include "string.hxx"
+#include "cell.hxx"
+
+extern "C"
+{
+#include "localization.h"
+#include "Scierror.h"
+#include "sciprint.h"
+#include "mgetl.h"
+#include "do_xxprintf.h"
+#include "do_xxscanf.h"
+#include "scanf_functions.h"
+}
+
+types::Function::ReturnValue sci_mfscanf(types::typed_list &in, int _iRetCount, types::typed_list &out)
+{
+    int iFile                   = -1; //default file : last opened file
+    int size                    = (int)in.size();
+    int iNiter                  = 1;
+    int iLinesRead              = 0;
+    int iErr                    = 0;
+    wchar_t* wcsFormat          = NULL;
+    wchar_t** wcsRead           = NULL;
+    int dimsArray[2]            = {1,1};
+    std::vector<types::InternalType*>* pIT = new std::vector<types::InternalType*>();
+
+    int args        = 0;
+    int nrow        = 0;
+    int ncol        = 0;
+    int retval      = 0;
+    int retval_s    = 0;
+    int rowcount    = -1;
+    rec_entry buf[MAXSCAN];
+    entry *data;
+    sfdir type[MAXSCAN],type_s[MAXSCAN];
+
+    if(size < 2 || size >3)
+    {
+       ScierrorW(77, _W("%ls: Wrong number of input argument(s): %d to %d expected.\n"), L"mfscanf", 2, 3);
+        return types::Function::Error;
+    }
+
+    if(size == 3)
+    {
+        if(in[0]->isDouble() == false || in[0]->getAs<types::Double>()->isScalar() == false || in[0]->getAs<types::Double>()->isComplex())
+        {
+            ScierrorW(999, _W("%ls: Wrong type for input argument #%d: A Real expected.\n"), L"mfscanf", 1);
+            return types::Function::Error;
+        }
+        iNiter = static_cast<int>(in[0]->getAs<types::Double>()->getReal()[0]);
+    }
+
+    if(in[size-2]->isDouble() == false || in[size-2]->getAs<types::Double>()->isScalar() == false || in[size-2]->getAs<types::Double>()->isComplex())
+    {
+        ScierrorW(999, _W("%ls: Wrong type for input argument #%d: A Real expected.\n"), L"mfscanf", size-1);
+        return types::Function::Error;
+    }
+
+    if(in[size-1]->isString() == false || in[size-1]->getAs<types::String>()->isScalar() == false)
+    {
+        ScierrorW(999, _W("%ls: Wrong type for input argument #%d: A String expected.\n"), L"mfscanf", size);
+        return types::Function::Error;
+    }
+
+    iFile = static_cast<int>(in[size-2]->getAs<types::Double>()->getReal()[0]);
+       switch (iFile)
+       {
+    case 0:
+        // stderr
+        ScierrorW(999, _W("%ls: Wrong file descriptor: %d.\n"), L"mfscanf", iFile);
+        return types::Function::Error;
+    case 6:
+        // stdout
+        ScierrorW(999, _W("%ls: Wrong file descriptor: %d.\n"), L"mfscanf", iFile);
+        return types::Function::Error;
+    default :
+        break;
+    }
+
+    wcsFormat = in[size-1]->getAs<types::String>()->get(0);
+
+// get data
+
+    wcsRead = mgetl(iFile, iNiter, &iLinesRead, &iErr);
+    switch(iErr)
+    {
+        case MGETL_NO_ERROR :
+        break;
+        case MGETL_EOF :
+            sciprintW(_W("Warning: Only %d line(s) read.\n"), iLinesRead);
+        break;
+        case MGETL_MEMORY_ALLOCATION_ERROR :
+            ScierrorW(999, _W("%ls: Memory allocation error in %ls function.\n"), L"mfscanf", L"mgetl");
+        return types::Function::Error;
+        case MGETL_ERROR :
+            ScierrorW(999, _W("%ls: Cannot read file %d.\n"), L"mfscanf", iFile);
+        return types::Function::Error;
+    }
+
+    nrow = iLinesRead;
+       while(++rowcount < iLinesRead)
+    {
+        if ((iLinesRead >= 0) && (rowcount >= iLinesRead)) break;
+        // get data
+        int err = do_xxscanf(L"sscanf",(FILE *)0,wcsFormat,&args,wcsRead[rowcount],&retval,buf,type);
+        if(err < 0) return types::Function::Error;
+        err=Store_Scan(&nrow,&ncol,type_s,type,&retval,&retval_s,buf,&data,rowcount,args);
+        if(err < 0)
+        {
+            switch (err)
+            {
+                case DO_XXPRINTF_MISMATCH:
+                    if (iLinesRead >= 0)
+                    {
+                        Free_Scan(rowcount,ncol,type_s,&data);
+                        ScierrorW(999,_W("%ls: Data mismatch.\n"),L"mfscanf");
+                        return types::Function::Error;
+                    }
+                break;
+
+                case DO_XXPRINTF_MEM_LACK:
+                    Free_Scan(rowcount,ncol,type_s,&data);
+                    ScierrorW(999,_W("%ls: No more memory.\n"),L"mfscanf");
+                    return types::Function::Error;
+                break;
+            }
+            if (err==DO_XXPRINTF_MISMATCH) break;
+        }
+        FREE(wcsRead[rowcount]);
+    }
+    FREE(wcsRead);
+    unsigned int uiFormatUsed = 0;
+    for(int i=0; i<ncol; i++)
+    {
+        switch ( type_s[i] )
+        {
+            case SF_C:
+            case SF_S:
+            {
+                types::String* ps = new types::String(iLinesRead,1);
+                for(int j=0; j<iLinesRead; j++)
+                {
+                    ps->set(j, data[i+ncol*j].s);
+                }
+                pIT->push_back(ps);
+                uiFormatUsed |= (1 << 1);
+            }
+            break;
+               case SF_LUI:
+            case SF_SUI:
+            case SF_UI:
+            case SF_LI:
+            case SF_SI:
+            case SF_I:
+            case SF_LF:
+            case SF_F:
+            {
+                types::Double* p = new types::Double(iLinesRead,1);
+                for(int j=0; j<iLinesRead; j++)
+                {
+                    p->set(j, data[i+ncol*j].d);
+                }
+                pIT->push_back(p);
+                uiFormatUsed |= (1 << 2);
+            }
+            break;
+        }
+    }
+
+    int sizeOfVector = (int)pIT->size();
+    if(_iRetCount > 1)
+    {
+        types::Double* pDouble = new types::Double(2,dimsArray);
+        pDouble->set(0,retval);
+        out.push_back(pDouble);
+
+        for(int i = 0; i < sizeOfVector; i++)
+        {
+            out.push_back((*pIT)[i]);
+        }
+        for(int i = sizeOfVector + 1; i < _iRetCount; i++)
+        {
+            out.push_back(types::Double::Empty());
+        }
+    }
+    else
+    {
+        if(sizeOfVector == 0)
+        {
+            out.push_back(types::Double::Empty());
+            return types::Function::OK;
+        }
+
+        switch(uiFormatUsed)
+        {
+            case (1 << 1) :
+            {
+                int sizeOfString = (*pIT)[0]->getAs<types::String>()->getRows();
+                int dimsArrayOfRes[2] = {sizeOfString, sizeOfVector};
+                types::String* pString = new types::String(2, dimsArrayOfRes);
+                for(int i = 0; i < sizeOfVector; i++)
+                {
+                    for(int j = 0; j < sizeOfString; j++)
+                    {
+                        pString->set(i*sizeOfString+j, (*pIT)[i]->getAs<types::String>()->get(j));
+                    }
+                }
+                out.push_back(pString);
+            }
+            break;
+            case (1 << 2) :
+            {
+                int sizeOfDouble = (*pIT)[0]->getAs<types::Double>()->getRows();
+                int dimsArrayOfRes[2] = {sizeOfDouble, sizeOfVector};
+                types::Double* pDouble = new types::Double(2, dimsArrayOfRes);
+                for(int i = 0; i < sizeOfVector; i++)
+                {
+                    for(int j = 0; j < sizeOfDouble; j++)
+                    {
+                        pDouble->set(i*sizeOfDouble+j, (*pIT)[i]->getAs<types::Double>()->get(j));
+                    }
+                }
+                out.push_back(pDouble);
+            }
+            break;
+            default :
+            {
+                std::vector<types::InternalType*>* pITTemp = new std::vector<types::InternalType*>();
+                pITTemp->push_back((*pIT)[0]);
+
+                // sizeOfVector always > 1
+                for(int i = 1; i < sizeOfVector; i++) // concatenates the Cells. ex : [String 4x1] [String 4x1] = [String 4x2]
+                {
+                    if(pITTemp->back()->getType() == (*pIT)[i]->getType())
+                    {
+                        switch(pITTemp->back()->getType())
+                        {
+                            case types::InternalType::RealString :
+                            {
+                                int iRows               = pITTemp->back()->getAs<types::String>()->getRows();
+                                int iCols               = pITTemp->back()->getAs<types::String>()->getCols();
+                                int arrayOfType[2]      = {iRows, iCols + 1};
+                                types::String* pType    = new types::String(2, arrayOfType);
+
+                                for(int k=0; k<pITTemp->back()->getAs<types::String>()->getSize(); k++)
+                                {
+                                    pType->set(k, pITTemp->back()->getAs<types::String>()->get(k));
+                                }
+                                for(int k=0; k<(*pIT)[i]->getAs<types::String>()->getSize(); k++)
+                                {
+                                    pType->set(iRows * iCols + k, (*pIT)[i]->getAs<types::String>()->get(k));
+                                }
+                                pITTemp->pop_back();
+                                pITTemp->push_back(pType);
+                            }
+                            break;
+                            case types::InternalType::RealDouble :
+                            {
+                                int iRows               = pITTemp->back()->getAs<types::Double>()->getRows();
+                                int iCols               = pITTemp->back()->getAs<types::Double>()->getCols();
+                                int arrayOfType[2]      = {iRows, iCols + 1};
+                                types::Double* pType    = new types::Double(2, arrayOfType);
+
+                                pType->set(pITTemp->back()->getAs<types::Double>()->get());
+                                for(int k=0; k<(*pIT)[i]->getAs<types::Double>()->getSize(); k++)
+                                {
+                                    pType->set(iRows * iCols + k, (*pIT)[i]->getAs<types::Double>()->get(k));
+                                }
+                                pITTemp->pop_back();
+                                pITTemp->push_back(pType);
+                            }
+                            break;
+                            default :
+                                return types::Function::Error;
+                        }
+                    }
+                    else
+                    {
+                        pITTemp->push_back((*pIT)[i]);
+                    }
+                }
+
+                int dimsArrayOfCell[2] = {1, (int)pITTemp->size()};
+                types::Cell* pCell = new types::Cell(2, dimsArrayOfCell);
+                for(int i = 0; i < pITTemp->size(); i++)
+                {
+                    pCell->set(i, (*pITTemp)[i]);
+                }
+                out.push_back(pCell);
+            }
+        }
+    }
+       Free_Scan(rowcount,ncol,type_s,&data);
+    return types::Function::OK;
+}
+/*--------------------------------------------------------------------------*/
+
index 9dd1d1b..9096991 100644 (file)
@@ -60,44 +60,9 @@ Function::ReturnValue sci_mputstr(types::typed_list &in, int _iRetCount, types::
         pdFileId = in[1]->getAs<types::Double>();
     }
 
-    int iErr = mputl(iFile, pString->get(), 1);
+    int iErr = mputl(iFile, pString->get(), 1, FALSE); // FALSE = don't add the "\n" at the end.
     out.push_back(new Bool(!iErr));
 
-/*
-    if(pdFileId != NULL)
-    {
-        iFile = static_cast<int>(pdFileId->getReal()[0]);
-        pF = FileManager::getFile(iFile);
-    }
-    else
-    {
-        pF = FileManager::getFile(iFile);
-    }
-        
-    if(pF != NULL)
-    {
-
-        if(fwprintf(pF->getFiledesc(),L"%ls",pString->get(0)) >= 0)
-        {
-            iRet = 1;
-        }
-        else
-        {
-            ScierrorW(999, _W("%ls: Error while writing.\n"), L"mputstr");
-        }
-    }
-    else
-    {
-        if (getWarningMode()) 
-        {
-            ScierrorW(999,_W("%ls: Cannot write in file whose descriptor is %d: File is not active.\n"), L"mputstr", iFile);
-        }
-        return types::Function::OK;
-    }
-    
-    Bool* pOut = new Bool(iRet);
-    out.push_back(pOut);
-*/
     return Function::OK;
 }
 /*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/fileio/sci_gateway/cpp/sci_mscanf.cpp b/scilab/modules/fileio/sci_gateway/cpp/sci_mscanf.cpp
new file mode 100644 (file)
index 0000000..b0ed61b
--- /dev/null
@@ -0,0 +1,271 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2006 - INRIA - Allan CORNET
+* Copyright (C) 2009 - DIGITEO - Allan CORNET
+* Copyright (C) 2010 - DIGITEO - Antoine ELIAS
+* Copyright (C) 2011 - DIGITEO - 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
+*
+*/
+/*--------------------------------------------------------------------------*/
+#include "fileio_gw.hxx"
+#include "string.hxx"
+#include "yaspio.hxx"
+#include "cell.hxx"
+
+extern "C"
+{
+#include "localization.h"
+#include "Scierror.h"
+#include "do_xxprintf.h"
+#include "do_xxscanf.h"
+#include "scanf_functions.h"
+}
+
+types::Function::ReturnValue sci_mscanf(types::typed_list &in, int _iRetCount, types::typed_list &out)
+{
+    int size                    = (int)in.size();
+    int iNiter                  = 1;
+    wchar_t* wcsFormat          = NULL;
+    wchar_t* wcsRead            = NULL;
+    int dimsArray[2]            = {1,1};
+    std::vector<types::InternalType*>* pIT = new std::vector<types::InternalType*>();
+
+    int args        = 0;
+    int nrow        = 0;
+    int ncol        = 0;
+    int retval      = 0;
+    int retval_s    = 0;
+    int rowcount    = -1;
+    rec_entry buf[MAXSCAN];
+    entry *data;
+    sfdir type[MAXSCAN],type_s[MAXSCAN];
+
+    if(size < 1 || size > 2)
+    {
+       ScierrorW(77, _W("%ls: Wrong number of input argument(s): %d to %d expected.\n"), L"mscanf", 1, 2);
+        return types::Function::Error;
+    }
+
+    if(size == 2)
+    {
+        if(in[0]->isDouble() == false || in[0]->getAs<types::Double>()->isScalar() == false || in[0]->getAs<types::Double>()->isComplex())
+        {
+            ScierrorW(999, _W("%ls: Wrong type for input argument #%d: A Real expected.\n"), L"mscanf", 1);
+            return types::Function::Error;
+        }
+        iNiter = static_cast<int>(in[0]->getAs<types::Double>()->getReal()[0]);
+        if(iNiter < 0)
+            iNiter = 1;
+    }
+
+    if(in[size-1]->isString() == false || in[size-1]->getAs<types::String>()->isScalar() == false)
+    {
+        ScierrorW(999, _W("%ls: Wrong type for input argument #%d: A String expected.\n"), L"mscanf", size);
+        return types::Function::Error;
+    }
+
+    wcsFormat = in[size-1]->getAs<types::String>()->get(0);
+    nrow = iNiter;
+       while(++rowcount < iNiter)
+    {
+        if ((iNiter >= 0) && (rowcount >= iNiter)) break;
+        // get data
+        wcsRead = to_wide_string(YaspRead());
+        int err = do_xxscanf(L"sscanf",(FILE *)0,wcsFormat,&args,wcsRead,&retval,buf,type);
+        if(err < 0) return types::Function::Error;
+        err=Store_Scan(&nrow,&ncol,type_s,type,&retval,&retval_s,buf,&data,rowcount,args);
+        if(err < 0)
+        {
+            switch (err)
+            {
+                case DO_XXPRINTF_MISMATCH:
+                    if (iNiter >= 0)
+                    {
+                        Free_Scan(rowcount,ncol,type_s,&data);
+                        ScierrorW(999,_W("%ls: Data mismatch.\n"),L"mscanf");
+                        return types::Function::Error;
+                    }
+                break;
+
+                case DO_XXPRINTF_MEM_LACK:
+                    Free_Scan(rowcount,ncol,type_s,&data);
+                    ScierrorW(999,_W("%ls: No more memory.\n"),L"mscanf");
+                    return types::Function::Error;
+                break;
+            }
+            if (err==DO_XXPRINTF_MISMATCH) break;
+        }
+        FREE(wcsRead);
+    }
+
+    unsigned int uiFormatUsed = 0;
+    for(int i=0; i<ncol; i++)
+    {
+        switch ( type_s[i] )
+        {
+            case SF_C:
+            case SF_S:
+            {
+                types::String* ps = new types::String(iNiter,1);
+                for(int j=0; j<iNiter; j++)
+                {
+                    ps->set(j, data[i+ncol*j].s);
+                }
+                pIT->push_back(ps);
+                uiFormatUsed |= (1 << 1);
+            }
+            break;
+               case SF_LUI:
+            case SF_SUI:
+            case SF_UI:
+            case SF_LI:
+            case SF_SI:
+            case SF_I:
+            case SF_LF:
+            case SF_F:
+            {
+                types::Double* p = new types::Double(iNiter,1);
+                for(int j=0; j<iNiter; j++)
+                {
+                    p->set(j, data[i+ncol*j].d);
+                }
+                pIT->push_back(p);
+                uiFormatUsed |= (1 << 2);
+            }
+            break;
+        }
+    }
+
+    int sizeOfVector = (int)pIT->size();
+    if(_iRetCount > 1)
+    {
+        types::Double* pDouble = new types::Double(2,dimsArray);
+        pDouble->set(0,retval);
+        out.push_back(pDouble);
+
+        for(int i = 0; i < sizeOfVector; i++)
+        {
+            out.push_back((*pIT)[i]);
+        }
+        for(int i = sizeOfVector + 1; i < _iRetCount; i++)
+        {
+            out.push_back(types::Double::Empty());
+        }
+    }
+    else
+    {
+        if(sizeOfVector == 0)
+        {
+            out.push_back(types::Double::Empty());
+            return types::Function::OK;
+        }
+
+        switch(uiFormatUsed)
+        {
+            case (1 << 1) :
+            {
+                int sizeOfString = (*pIT)[0]->getAs<types::String>()->getRows();
+                int dimsArrayOfRes[2] = {sizeOfString, sizeOfVector};
+                types::String* pString = new types::String(2, dimsArrayOfRes);
+                for(int i = 0; i < sizeOfVector; i++)
+                {
+                    for(int j = 0; j < sizeOfString; j++)
+                    {
+                        pString->set(i*sizeOfString+j, (*pIT)[i]->getAs<types::String>()->get(j));
+                    }
+                }
+                out.push_back(pString);
+            }
+            break;
+            case (1 << 2) :
+            {
+                int sizeOfDouble = (*pIT)[0]->getAs<types::Double>()->getRows();
+                int dimsArrayOfRes[2] = {sizeOfDouble, sizeOfVector};
+                types::Double* pDouble = new types::Double(2, dimsArrayOfRes);
+                for(int i = 0; i < sizeOfVector; i++)
+                {
+                    for(int j = 0; j < sizeOfDouble; j++)
+                    {
+                        pDouble->set(i*sizeOfDouble+j, (*pIT)[i]->getAs<types::Double>()->get(j));
+                    }
+                }
+                out.push_back(pDouble);
+            }
+            break;
+            default :
+            {
+                std::vector<types::InternalType*>* pITTemp = new std::vector<types::InternalType*>();
+                pITTemp->push_back((*pIT)[0]);
+
+                // sizeOfVector always > 1
+                for(int i = 1; i < sizeOfVector; i++) // concatenates the Cells. ex : [String 4x1] [String 4x1] = [String 4x2]
+                {
+                    if(pITTemp->back()->getType() == (*pIT)[i]->getType())
+                    {
+                        switch(pITTemp->back()->getType())
+                        {
+                            case types::InternalType::RealString :
+                            {
+                                int iRows               = pITTemp->back()->getAs<types::String>()->getRows();
+                                int iCols               = pITTemp->back()->getAs<types::String>()->getCols();
+                                int arrayOfType[2]      = {iRows, iCols + 1};
+                                types::String* pType    = new types::String(2, arrayOfType);
+
+                                for(int k=0; k<pITTemp->back()->getAs<types::String>()->getSize(); k++)
+                                {
+                                    pType->set(k, pITTemp->back()->getAs<types::String>()->get(k));
+                                }
+                                for(int k=0; k<(*pIT)[i]->getAs<types::String>()->getSize(); k++)
+                                {
+                                    pType->set(iRows * iCols + k, (*pIT)[i]->getAs<types::String>()->get(k));
+                                }
+                                pITTemp->pop_back();
+                                pITTemp->push_back(pType);
+                            }
+                            break;
+                            case types::InternalType::RealDouble :
+                            {
+                                int iRows               = pITTemp->back()->getAs<types::Double>()->getRows();
+                                int iCols               = pITTemp->back()->getAs<types::Double>()->getCols();
+                                int arrayOfType[2]      = {iRows, iCols + 1};
+                                types::Double* pType    = new types::Double(2, arrayOfType);
+
+                                pType->set(pITTemp->back()->getAs<types::Double>()->get());
+                                for(int k=0; k<(*pIT)[i]->getAs<types::Double>()->getSize(); k++)
+                                {
+                                    pType->set(iRows * iCols + k, (*pIT)[i]->getAs<types::Double>()->get(k));
+                                }
+                                pITTemp->pop_back();
+                                pITTemp->push_back(pType);
+                            }
+                            break;
+                            default :
+                                return types::Function::Error;
+                        }
+                    }
+                    else
+                    {
+                        pITTemp->push_back((*pIT)[i]);
+                    }
+                }
+
+                int dimsArrayOfCell[2] = {1, (int)pITTemp->size()};
+                types::Cell* pCell = new types::Cell(2, dimsArrayOfCell);
+                for(int i = 0; i < pITTemp->size(); i++)
+                {
+                    pCell->set(i, (*pITTemp)[i]);
+                }
+                out.push_back(pCell);
+            }
+        }
+    }
+       Free_Scan(rowcount,ncol,type_s,&data);
+    return types::Function::OK;
+}
+/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/fileio/sci_gateway/cpp/sci_msscanf.cpp b/scilab/modules/fileio/sci_gateway/cpp/sci_msscanf.cpp
new file mode 100644 (file)
index 0000000..b8185a5
--- /dev/null
@@ -0,0 +1,276 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2006 - INRIA - Allan CORNET
+* Copyright (C) 2009 - DIGITEO - Allan CORNET
+* Copyright (C) 2010 - DIGITEO - Antoine ELIAS
+* Copyright (C) 2011 - DIGITEO - 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
+*
+*/
+/*--------------------------------------------------------------------------*/
+#include "fileio_gw.hxx"
+#include "string.hxx"
+#include "cell.hxx"
+
+extern "C"
+{
+#include "localization.h"
+#include "Scierror.h"
+#include "do_xxprintf.h"
+#include "do_xxscanf.h"
+#include "scanf_functions.h"
+}
+
+types::Function::ReturnValue sci_msscanf(types::typed_list &in, int _iRetCount, types::typed_list &out)
+{
+    int size                    = (int)in.size();
+    int iNiter                  = 1;
+    wchar_t* wcsFormat          = NULL;
+    types::String* pStrRead     = NULL;
+    int dimsArray[2]            = {1,1};
+    std::vector<types::InternalType*>* pIT = new std::vector<types::InternalType*>();
+
+    int args        = 0;
+    int nrow        = 0;
+    int ncol        = 0;
+    int retval      = 0;
+    int retval_s    = 0;
+    int rowcount    = -1;
+    rec_entry buf[MAXSCAN];
+    entry *data;
+    sfdir type[MAXSCAN],type_s[MAXSCAN];
+
+    if(size < 2 || size >3)
+    {
+       ScierrorW(77, _W("%ls: Wrong number of input argument(s): %d to %d expected.\n"), L"msscanf", 2, 3);
+        return types::Function::Error;
+    }
+
+    if(size == 3)
+    {
+        if(in[0]->isDouble() == false || in[0]->getAs<types::Double>()->isScalar() == false || in[0]->getAs<types::Double>()->isComplex())
+        {
+            ScierrorW(999, _W("%ls: Wrong type for input argument #%d: A Real expected.\n"), L"msscanf", 1);
+            return types::Function::Error;
+        }
+        iNiter = static_cast<int>(in[0]->getAs<types::Double>()->getReal()[0]);
+    }
+
+    if(in[size-2]->isString() == false)
+    {
+        ScierrorW(999, _W("%ls: Wrong type for input argument #%d: A Strings expected.\n"), L"msscanf", size-1);
+        return types::Function::Error;
+    }
+
+    if(in[size-1]->isString() == false || in[size-1]->getAs<types::String>()->isScalar() == false)
+    {
+        ScierrorW(999, _W("%ls: Wrong type for input argument #%d: A String expected.\n"), L"msscanf", size);
+        return types::Function::Error;
+    }
+
+    pStrRead  = in[size-2]->getAs<types::String>();
+    if(iNiter == -1)
+    {
+        iNiter = pStrRead->getRows();
+    }
+    wcsFormat = in[size-1]->getAs<types::String>()->get(0);
+    nrow = iNiter;
+       while(++rowcount < iNiter)
+    {
+        if ((iNiter >= 0) && (rowcount >= iNiter)) break;
+        int err = do_xxscanf(L"sscanf",(FILE *)0,wcsFormat,&args,pStrRead->get(rowcount),&retval,buf,type);
+        if(err < 0) return types::Function::Error;
+        err=Store_Scan(&nrow,&ncol,type_s,type,&retval,&retval_s,buf,&data,rowcount,args);
+        if(err < 0)
+        {
+            switch (err)
+            {
+                case DO_XXPRINTF_MISMATCH:
+                    if (iNiter >= 0)
+                    {
+                        Free_Scan(rowcount,ncol,type_s,&data);
+                        ScierrorW(999,_W("%ls: Data mismatch.\n"),L"msscanf");
+                        return types::Function::Error;
+                    }
+                break;
+
+                case DO_XXPRINTF_MEM_LACK:
+                    Free_Scan(rowcount,ncol,type_s,&data);
+                    ScierrorW(999,_W("%ls: No more memory.\n"),L"msscanf");
+                    return types::Function::Error;
+                break;
+            }
+            if (err==DO_XXPRINTF_MISMATCH) break;
+        }
+    }
+
+    unsigned int uiFormatUsed = 0;
+    for(int i=0; i<ncol; i++)
+    {
+        switch ( type_s[i] )
+        {
+            case SF_C:
+            case SF_S:
+            {
+                types::String* ps = new types::String(iNiter,1);
+                for(int j=0; j<iNiter; j++)
+                {
+                    ps->set(j, data[i+ncol*j].s);
+                }
+                pIT->push_back(ps);
+                uiFormatUsed |= (1 << 1);
+            }
+            break;
+               case SF_LUI:
+            case SF_SUI:
+            case SF_UI:
+            case SF_LI:
+            case SF_SI:
+            case SF_I:
+            case SF_LF:
+            case SF_F:
+            {
+                types::Double* p = new types::Double(iNiter,1);
+                for(int j=0; j<iNiter; j++)
+                {
+                    p->set(j, data[i+ncol*j].d);
+                }
+                pIT->push_back(p);
+                uiFormatUsed |= (1 << 2);
+            }
+            break;
+        }
+    }
+
+    int sizeOfVector = (int)pIT->size();
+    if(_iRetCount > 1)
+    {
+        types::Double* pDouble = new types::Double(2,dimsArray);
+        pDouble->set(0,retval);
+        out.push_back(pDouble);
+
+        for(int i = 0; i < sizeOfVector; i++)
+        {
+            out.push_back((*pIT)[i]);
+        }
+        for(int i = sizeOfVector + 1; i < _iRetCount; i++)
+        {
+            out.push_back(types::Double::Empty());
+        }
+    }
+    else
+    {
+        if(sizeOfVector == 0)
+        {
+            out.push_back(types::Double::Empty());
+            return types::Function::OK;
+        }
+
+        switch(uiFormatUsed)
+        {
+            case (1 << 1) :
+            {
+                int sizeOfString = (*pIT)[0]->getAs<types::String>()->getRows();
+                int dimsArrayOfRes[2] = {sizeOfString, sizeOfVector};
+                types::String* pString = new types::String(2, dimsArrayOfRes);
+                for(int i = 0; i < sizeOfVector; i++)
+                {
+                    for(int j = 0; j < sizeOfString; j++)
+                    {
+                        pString->set(i*sizeOfString+j, (*pIT)[i]->getAs<types::String>()->get(j));
+                    }
+                }
+                out.push_back(pString);
+            }
+            break;
+            case (1 << 2) :
+            {
+                int sizeOfDouble = (*pIT)[0]->getAs<types::Double>()->getRows();
+                int dimsArrayOfRes[2] = {sizeOfDouble, sizeOfVector};
+                types::Double* pDouble = new types::Double(2, dimsArrayOfRes);
+                for(int i = 0; i < sizeOfVector; i++)
+                {
+                    for(int j = 0; j < sizeOfDouble; j++)
+                    {
+                        pDouble->set(i*sizeOfDouble+j, (*pIT)[i]->getAs<types::Double>()->get(j));
+                    }
+                }
+                out.push_back(pDouble);
+            }
+            break;
+            default :
+            {
+                std::vector<types::InternalType*>* pITTemp = new std::vector<types::InternalType*>();
+                pITTemp->push_back((*pIT)[0]);
+
+                // sizeOfVector always > 1
+                for(int i = 1; i < sizeOfVector; i++) // concatenates the Cells. ex : [String 4x1] [String 4x1] = [String 4x2]
+                {
+                    if(pITTemp->back()->getType() == (*pIT)[i]->getType())
+                    {
+                        switch(pITTemp->back()->getType())
+                        {
+                            case types::InternalType::RealString :
+                            {
+                                int iRows               = pITTemp->back()->getAs<types::String>()->getRows();
+                                int iCols               = pITTemp->back()->getAs<types::String>()->getCols();
+                                int arrayOfType[2]      = {iRows, iCols + 1};
+                                types::String* pType    = new types::String(2, arrayOfType);
+
+                                for(int k=0; k<pITTemp->back()->getAs<types::String>()->getSize(); k++)
+                                {
+                                    pType->set(k, pITTemp->back()->getAs<types::String>()->get(k));
+                                }
+                                for(int k=0; k<(*pIT)[i]->getAs<types::String>()->getSize(); k++)
+                                {
+                                    pType->set(iRows * iCols + k, (*pIT)[i]->getAs<types::String>()->get(k));
+                                }
+                                pITTemp->pop_back();
+                                pITTemp->push_back(pType);
+                            }
+                            break;
+                            case types::InternalType::RealDouble :
+                            {
+                                int iRows               = pITTemp->back()->getAs<types::Double>()->getRows();
+                                int iCols               = pITTemp->back()->getAs<types::Double>()->getCols();
+                                int arrayOfType[2]      = {iRows, iCols + 1};
+                                types::Double* pType    = new types::Double(2, arrayOfType);
+
+                                pType->set(pITTemp->back()->getAs<types::Double>()->get());
+                                for(int k=0; k<(*pIT)[i]->getAs<types::Double>()->getSize(); k++)
+                                {
+                                    pType->set(iRows * iCols + k, (*pIT)[i]->getAs<types::Double>()->get(k));
+                                }
+                                pITTemp->pop_back();
+                                pITTemp->push_back(pType);
+                            }
+                            break;
+                            default :
+                                return types::Function::Error;
+                        }
+                    }
+                    else
+                    {
+                        pITTemp->push_back((*pIT)[i]);
+                    }
+                }
+
+                int dimsArrayOfCell[2] = {1, (int)pITTemp->size()};
+                types::Cell* pCell = new types::Cell(2, dimsArrayOfCell);
+                for(int i = 0; i < pITTemp->size(); i++)
+                {
+                    pCell->set(i, (*pITTemp)[i]);
+                }
+                out.push_back(pCell);
+            }
+        }
+    }
+       Free_Scan(rowcount,ncol,type_s,&data);
+    return types::Function::OK;
+}
+/*--------------------------------------------------------------------------*/
index e1cb56d..c145a2a 100644 (file)
 #include "do_xxprintf.h"
 #include "core_math.h"
 /*--------------------------------------------------------------------------*/
-typedef int (*XXSCANF)(FILE *, char *,...);
+typedef int (*XXSCANF)(FILE *, wchar_t *,...);
 typedef int (*FLUSH)(FILE *);
 /*--------------------------------------------------------------------------*/
-static void set_xxscanf(FILE *fp,XXSCANF *xxscanf,char **target,char **strv)
+static void set_xxscanf(FILE *fp,XXSCANF *xxscanf,wchar_t **target,wchar_t **strv)
 {
        if (fp == (FILE *) 0)
        {
                *target = *strv;
-               *xxscanf = (XXSCANF) sscanf;
+               *xxscanf = (XXSCANF) swscanf;
        }
        else
        {
-               *target = (char *) fp;
-               *xxscanf = (XXSCANF) fscanf;
+               *target = (wchar_t *) fp;
+               *xxscanf = (XXSCANF) fwscanf;
        }
 }
 /*--------------------------------------------------------------------------*/
-int do_xxscanf (char *fname, FILE *fp, char *format, int *nargs, char *strv, int *retval, rec_entry *buf, sfdir *type)
+int do_xxscanf (wchar_t *fname, FILE *fp, wchar_t *format, int *nargs, wchar_t *strv, int *retval, rec_entry *buf, sfdir *type)
 {
        int nc[MAXSCAN];
        int n_directive_count=0;
@@ -56,14 +56,14 @@ int do_xxscanf (char *fname, FILE *fp, char *format, int *nargs, char *strv, int
        int str_width_flag=0;
        int num_conversion = -1;
        void *ptrtab[MAXSCAN];
-       char sformat[MAX_STR];
-       char backupcurrrentchar;
-       char directive;
-       char *p=NULL;
-       char *p1=NULL;
-       char *target=NULL;
-       char *sval=NULL;
-       register char *currentchar=NULL;
+       wchar_t sformat[MAX_STR];
+       wchar_t backupcurrrentchar;
+       wchar_t directive;
+       wchar_t *p=NULL;
+       wchar_t *p1=NULL;
+       wchar_t *target=NULL;
+       wchar_t *sval=NULL;
+       register wchar_t *currentchar=NULL;
 
        XXSCANF xxscanf;
 
@@ -96,10 +96,10 @@ int do_xxscanf (char *fname, FILE *fp, char *format, int *nargs, char *strv, int
 
                if ( p1+1 != currentchar )
                {
-                       char w= *currentchar;
+                       wchar_t w= *currentchar;
                        *currentchar='\0';
                        width_flag = 1;
-                       sscanf(p1+1,"%d",&width_val);
+                       swscanf(p1+1,L"%d",&width_val);
                        *currentchar=w;
                }
 
@@ -132,7 +132,7 @@ int do_xxscanf (char *fname, FILE *fp, char *format, int *nargs, char *strv, int
 
                if ( directive == '[' )
                {
-                       char *currentchar1=currentchar--;
+                       wchar_t *currentchar1=currentchar--;
                        while ( *currentchar1 != '\0' && *currentchar1 != ']') currentchar1++;
 
                        if ( *currentchar1 == '\0')
@@ -141,7 +141,7 @@ int do_xxscanf (char *fname, FILE *fp, char *format, int *nargs, char *strv, int
                                return DO_XXPRINTF_RET_BUG;
                        }
 
-                       if ( currentchar1 == currentchar +1 || strncmp(currentchar,"[^]",3)==0 )
+                       if ( currentchar1 == currentchar +1 || wcsncmp(currentchar,"[^]",3)==0 )
                        {
                                currentchar1++;
                                while ( *currentchar1 != '\0' && *currentchar1 != ']') currentchar1++;
@@ -172,7 +172,7 @@ int do_xxscanf (char *fname, FILE *fp, char *format, int *nargs, char *strv, int
                        switch (directive )
                        {
                        case ']':
-                               if (width_flag == 0 ) str_width_flag = 1;
+                               /*if (width_flag == 0 )*/ str_width_flag = 1;
 
                                if (width_flag == 1 && width_val > MAX_STR-1 )
                                {
@@ -186,13 +186,13 @@ int do_xxscanf (char *fname, FILE *fp, char *format, int *nargs, char *strv, int
                                break;
 
                        case 's':
-                               if (l_flag + h_flag)
+                               if (/*l_flag +*/ h_flag)
                                {
                                        Scierror(998,_("%s: An error occurred: %s\n"),fname,_("Bad conversion."));
                                        return DO_XXPRINTF_RET_BUG;
                                }
 
-                               if (width_flag == 0 ) str_width_flag = 1;
+                               /*if (width_flag == 0 )*/ str_width_flag = 1;
                                if (width_flag == 1 && width_val > MAX_STR-1 )
                                {
                                        Scierror(998,_("%s: An error occurred: field %d is too long (< %d) for %%s directive.\n"),fname,width_val,MAX_STR-1);
@@ -206,12 +206,12 @@ int do_xxscanf (char *fname, FILE *fp, char *format, int *nargs, char *strv, int
                                break;
 
                        case 'c':
-                               if (l_flag + h_flag)
+                               if (/*l_flag +*/ h_flag)
                                {
                                        Scierror(998,_("%s: An error occurred: %s\n"),fname,_("Bad conversion."));
                                        return DO_XXPRINTF_RET_BUG;
                                }
-
+                str_width_flag = 1;
                                if ( width_flag == 1 ) nc[num_conversion ] = width_val;
                                else nc[num_conversion ] = 1;
 
@@ -300,18 +300,37 @@ int do_xxscanf (char *fname, FILE *fp, char *format, int *nargs, char *strv, int
 
        if ( str_width_flag == 1)
        {
-               char *f1=format;
-               char *f2=sformat;
-               char *slast = sformat + MAX_STR - 1 - 4;
+               wchar_t *f1=format;
+               wchar_t *f2=sformat;
+               wchar_t *slast = sformat + MAX_STR - 1 - 4;
 
+        int bFirst = 1;
                while ( *f1 != '\0'  )
                {
                        int n;
+                       if(*(f1) == '%')
+                       {
+                bFirst = 1;
+                       }
                        *f2++ = *f1++;
-
-                       if ( *(f1-1) == '%' && ( *(f1) == 's'  || *(f1) == '['))
+            if(bFirst && ( *(f1) == 's'  || *(f1) == '[' || *(f1) == 'c'))
+            {
+                bFirst = 0;
+                if(*(f1-1) != 'l' && *(f1-1) != 'L')
+                {
+                    *f2++  = L'l';
+                }
+            }
+                       if( (*(f1) == 's' || *(f1) == '[') 
+                           && 
+                           (   (*(f1-1) == '%') 
+                               || 
+                    ((*(f1-1) == 'l' || *(f1-1) == 'L') && (*(f1-2) == '%'))
+                )
+              )
                        {
-                               n=sprintf(f2,"%d",MAX_STR-1);
+                           f2--;
+                               n=swprintf(f2,MAX_STR-1,L"%d%c",MAX_STR-1,L'l');
                                f2 += n;
                                *f2++ = *f1++;
                        }
@@ -345,7 +364,7 @@ int do_xxscanf (char *fname, FILE *fp, char *format, int *nargs, char *strv, int
        {
                if ( type[i-1]  == SF_C )
                {
-                       sval=(char *) ptrtab[i-1];
+                       sval=(wchar_t *) ptrtab[i-1];
                        sval[nc[i-1]]='\0';
                }
        }
index 053e7d1..a8879ae 100644 (file)
@@ -285,7 +285,7 @@ char *normalizeFileSeparator(const char *path)
 wchar_t *normalizeFileSeparatorW(const wchar_t *path)
 {
     // TODO : Implement strsubW to have same behaviour.
-    return path;
+    return (wchar_t*)path;
 }
 /* ================================================================================== */
 
index 4c11c95..24a7cc5 100644 (file)
@@ -123,7 +123,7 @@ wchar_t* getshortpathnameW(wchar_t* _pwstLongPathName, BOOL* _pbOK)
             }
             else
             {
-                FREE(_pwstLongPathName);
+                FREE(pwstOutput);
                 pwstOutput = os_wcsdup(_pwstLongPathName);
                 *_pbOK = FALSE;
             }
index cc618d7..0ec1a0a 100644 (file)
 #include "cvstr.h"
 #include "localization.h"
 #include "Scierror.h"
-/*--------------------------------------------------------------------------*/
-int Sci_Store(int nrow, int ncol, entry *data, sfdir *type, int retval_s)
-{
-  int cur_i,i,j,i1,one=1,zero=0,k,l,iarg,colcount;
-  sfdir cur_type;
-  char ** temp;
-
-
-  /* create Scilab variable with each column of data */
-  if (ncol+Rhs > intersiz ){
-    Scierror(998,_("%s: Too many directives in scanf.\n"),"Sci_Store");
-    return DO_XXPRINTF_RET_BUG;
-  }
-  iarg=Rhs;
-  if (Lhs > 1) {
-    if (nrow==0) {/* eof encountered before any data */
-      CreateVar(++iarg,MATRIX_OF_DOUBLE_DATATYPE, &one, &one, &l);
-      LhsVar(1) = iarg;
-      *stk(l) = -1.0;
-      for ( i = 2; i <= Lhs ; i++)
-      {
-       iarg++;
-       CreateVar(iarg,MATRIX_OF_DOUBLE_DATATYPE,&zero,&zero,&l);
-       LhsVar(i) = iarg;
-      }
-      PutLhsVar();
-      return 0;
-    }
-    CreateVar(++iarg,MATRIX_OF_DOUBLE_DATATYPE, &one, &one, &l);
-    *stk(l) = (double) retval_s;
-    LhsVar(1)=iarg;
-    if (ncol==0) goto Complete;
-
-    for ( i=0 ; i < ncol ; i++) {
-      if ( (type[i] == SF_C) || (type[i] == SF_S) ) {
-       if( (temp = (char **) MALLOC(nrow*ncol*sizeof(char **)))==NULL) return DO_XXPRINTF_MEM_LACK;
-       k=0;
-       for (j=0;j<nrow;j++) temp[k++]=data[i+ncol*j].s;
-       CreateVarFromPtr(++iarg,MATRIX_OF_STRING_DATATYPE, &nrow, &one, temp);
-       FREE(temp);
-       /*for (j=0;j<nrow;j++) FREE(data[i+ncol*j].s);*/
-      }
-      else {
-       CreateVar(++iarg,MATRIX_OF_DOUBLE_DATATYPE, &nrow, &one, &l);
-       for ( j=0 ; j < nrow ; j++)
-         *stk(l+j)= data[i+ncol*j].d;
-      }
-
-      LhsVar(i+2)=iarg;
-    }
-    /*FREE(data);*/
-    /** we must complete the returned arguments up to Lhs **/
-  Complete:
-    for ( i = ncol+2; i <= Lhs ; i++)
-      {
-       iarg++;
-       CreateVar(iarg,MATRIX_OF_DOUBLE_DATATYPE,&zero,&zero,&l);
-       LhsVar(i) = iarg;
-      }
-  }
-  else {/* Lhs==1 */
-    char *ltype="cblock";
-    int multi=0,endblk,ii,n;
-
-    cur_type=type[0];
 
-    for (i=0;i<ncol;i++)
-      if (type[i] != cur_type)         {
-       multi=1;
-       break;
-      }
-    if (multi) {
-      i=(int)strlen(ltype);
-      iarg=Rhs;
-      CreateVarFromPtr(++iarg,STRING_DATATYPE, &one, &i, &ltype); /* the mlist type field */
-      cur_type=type[0];
-      i=0;cur_i=i;
-
-      while (1) {
-       if (i < ncol)
-         endblk=(type[i] != cur_type);
-       else
-         endblk=1;
-       if (endblk) {
-         colcount=i - cur_i;
-         if (nrow==0) {
-           CreateVar(++iarg,MATRIX_OF_DOUBLE_DATATYPE, &zero, &zero, &l);}
-         else if ( (cur_type == SF_C) || (cur_type == SF_S) ) {
-           if( (temp = (char **) MALLOC(nrow*colcount*sizeof(char **)))==NULL) return DO_XXPRINTF_MEM_LACK;
-           k=0;
-           for (i1=cur_i;i1<i;i1++)
-             for (j=0;j<nrow;j++) temp[k++]=data[i1+ncol*j].s;
-           CreateVarFromPtr(++iarg,MATRIX_OF_STRING_DATATYPE, &nrow, &colcount,temp);
-           FREE(temp);
-           /*for (i1=cur_i;i1<i;i1++)
-             for (j=0;j<nrow;j++) FREE(data[i1+ncol*j].s);*/
-         }
-         else {
-           CreateVar(++iarg,MATRIX_OF_DOUBLE_DATATYPE, &nrow, &colcount, &l);
-           ii=0;
-           for (i1=cur_i;i1<i;i1++) {
-             for ( j=0 ; j < nrow ; j++)
-               *stk(l+j+nrow*ii)= data[i1+ncol*j].d;
-             ii++;
-           }
-         }
-         if (i>=ncol) break;
-         cur_i=i;
-         cur_type=type[i];
-
-       }
-       i++;
-      }
-      n=iarg-Rhs; /* number of list fields*/
-
-      iarg++;
-      i=Rhs+1;
-      C2F(mkmlistfromvars)(&i,&n);
-      LhsVar(1)=i;
-    }
-    else {
-      if (nrow==0) {
-       CreateVar(Rhs+1,MATRIX_OF_DOUBLE_DATATYPE, &zero, &zero, &l);}
-      else if ( (cur_type == SF_C) || (cur_type == SF_S) ) {
-       if( (temp = (char **) MALLOC(nrow*ncol*sizeof(char **)))==NULL) return DO_XXPRINTF_MEM_LACK;
-       k=0;
-       for (i1=0;i1<ncol;i1++)
-         for (j=0;j<nrow;j++) temp[k++]=data[i1+ncol*j].s;
-       CreateVarFromPtr(Rhs+1,MATRIX_OF_STRING_DATATYPE, &nrow, &ncol, temp);
-       FREE(temp);
-       /*for (i1=0;i1<ncol;i1++)
-         for (j=0;j<nrow;j++) FREE(data[i1+ncol*j].s);*/
-      }
-      else {
-       CreateVar(Rhs+1,MATRIX_OF_DOUBLE_DATATYPE, &nrow, &ncol, &l);
-       ii=0;
-       for (i1=0;i1<ncol;i1++) {
-         for ( j=0 ; j < nrow ; j++)
-           *stk(l+j+nrow*ii)= data[i1+ncol*j].d;
-         ii++;
-       }
-      }
-    }
-    LhsVar(1)=Rhs+1;
-  }
-  PutLhsVar();
-  return 0;
-}
-/*--------------------------------------------------------------------------*/
 /* ************************************************************************
  *   Store data scanned by a single call to do_scan in line rowcount of data
  *   table
index 102bea2..d14af87 100644 (file)
@@ -31,7 +31,6 @@ wchar_t* mgetstr(int _iFileId, int _iSizeToRead)
     {
         if(static_cast<int>(pF->getFileModeAsDouble()) % 2 == 1)
         {
-            printf("Binary mode\n");
             pwstOut = (wchar_t*)MALLOC(iSizeToRead * sizeof(wchar_t));
             memset(pwstOut, 0x00, iSizeToRead * sizeof(wchar_t));
             wchar_t* pwstRes = fgetws(pwstOut, iSizeToRead, pF->getFiledesc());
@@ -43,7 +42,6 @@ wchar_t* mgetstr(int _iFileId, int _iSizeToRead)
         }
         else
         {
-            printf("Text mode\n");
             char* buffer = (char*)MALLOC(iSizeToRead * sizeof(char));
             memset(buffer, 0x00, iSizeToRead * sizeof(char));
 
index 3265680..149e98f 100644 (file)
@@ -24,7 +24,7 @@ extern "C"
 /*--------------------------------------------------------------------------*/
 #define MPUTL_FORMAT "%s\n"
 /*--------------------------------------------------------------------------*/
-mputlError mputl(int _iFileId, wchar_t **pstStrings, int _iSizeStrings)
+mputlError mputl(int _iFileId, wchar_t **pstStrings, int _iSizeStrings, BOOL _CR)
 {
     int i = 0;
     File* pF = NULL;
@@ -54,7 +54,6 @@ mputlError mputl(int _iFileId, wchar_t **pstStrings, int _iSizeStrings)
         }
     }
 
-
     //export in UTF-8 if file is not open in binary mode
     if(static_cast<int>(pF->getFileModeAsDouble()) % 2 == 1)
     {//binary mode
@@ -64,10 +63,12 @@ mputlError mputl(int _iFileId, wchar_t **pstStrings, int _iSizeStrings)
             {
                 return MPUTL_ERROR;
             }
-
-            if(fputws(L"\n", pF->getFiledesc()) == -1)
+            if(_CR)
             {
-                return MPUTL_ERROR;
+                if(fputws(L"\n", pF->getFiledesc()) == -1)
+                {
+                    return MPUTL_ERROR;
+                }
             }
         }
     }
@@ -75,18 +76,21 @@ mputlError mputl(int _iFileId, wchar_t **pstStrings, int _iSizeStrings)
     {//text mode
         for (i = 0; i < _iSizeStrings; i++)
         {
-            char* pstTemp = wide_string_to_UTF8(pstStrings[i]);
+            char* pstTemp = NULL;
+            pstTemp = wide_string_to_UTF8(pstStrings[i]);
             int iRet = fputs(pstTemp, pF->getFiledesc());
             FREE(pstTemp);
             if(iRet == -1)
             {
                 return MPUTL_ERROR;
             }
-
-            iRet = fputs("\n", pF->getFiledesc());
-            if(iRet == -1)
+            if(_CR)
             {
-                return MPUTL_ERROR;
+                iRet = fputs("\n", pF->getFiledesc());
+                if(iRet == -1)
+                {
+                    return MPUTL_ERROR;
+                }
             }
         }
     }
index cb04c80..54d1362 100644 (file)
@@ -35,7 +35,7 @@ typedef enum {
 * @param[in] numbers of strings to write
 * @return enum error
 */
-FILEIO_IMPEXP mputlError mputl(int _iFileId, wchar_t **pstStrings, int _iSizeStrings);
+FILEIO_IMPEXP mputlError mputl(int _iFileId, wchar_t **pstStrings, int _iSizeStrings, BOOL _CR = TRUE);
 
 #endif /* __MPUTL_H__ */
 /*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/fileio/src/cpp/scilab_sscanf.cpp b/scilab/modules/fileio/src/cpp/scilab_sscanf.cpp
new file mode 100644 (file)
index 0000000..6ca187f
--- /dev/null
@@ -0,0 +1,781 @@
+/*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2011 - DIGITEO - 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
+ *
+ */
+
+#include "types.hxx"
+#include "double.hxx"
+#include "string.hxx"
+#include "scilab_sscanf.hxx"
+#include "int.hxx"
+
+extern "C"
+{
+#include <stdio.h>
+#include "Scierror.h"
+#include "MALLOC.h"
+#include "localization.h"
+#include "charEncoding.h"
+#include "BOOL.h"
+#include "os_wcstok.h"
+}
+
+static wchar_t* findChars(wchar_t*, BOOL*); // Use to find what is inside the [] when the format is %[...].
+
+int scilab_sscanf(wchar_t* _wcsFormat, wchar_t* _wcsData, int _iIterrator, int _iNiter, std::vector<types::InternalType*> *_pITOut)
+{
+    int i                       = 0;
+    int j                       = 0;
+    int nbrOfDigit              = 0;
+    int dims                    = 2;
+    int dimsArray[2]            = {_iNiter,1};
+    BOOL bStar                  = FALSE;
+    BOOL bUnsigned              = FALSE;
+    BOOL bNegatif               = FALSE;
+    BOOL bIgnoredChars          = TRUE;
+    int base                    = 0;
+    wchar_t wcsLLH              = L' ';
+    wchar_t* wcsData            = NULL;
+    int sizeOfData              = wcslen(_wcsData);
+    int iCountDataRead          = 0;
+
+    wcsData = (wchar_t*)MALLOC((sizeOfData + 1) * sizeof(wchar_t));
+    memcpy(wcsData, _wcsData, sizeOfData * sizeof(wchar_t));
+    wcsData[sizeOfData] = '\0';
+
+    while(i < (int)wcslen(_wcsFormat))
+    {
+        while(bIgnoredChars && i < (int)wcslen(_wcsFormat)) // %da%s => 'a' is an ignored char.
+        {
+            if(wcsData != NULL && wcsData[0] != L'\0' && _wcsFormat[i] == wcsData[0])
+            {
+                if(_wcsFormat[i] != L' ')
+                {
+                    i++;
+                    wcsData++;
+                }
+                else
+                {
+                    while(wcsData[0] == L' ')
+                    {
+                        wcsData++;
+                    }
+                    while(_wcsFormat[i] == L' ')
+                    {
+                        i++;
+                    }
+                }
+            }
+            else if((wcsData == NULL || wcsData[0] == L'\0') && i < (int)wcslen(_wcsFormat) && iCountDataRead == 0 && _pITOut->size() == 0)
+            {
+                iCountDataRead = -1;
+            }
+            else
+            {
+                if(_wcsFormat[i] == L' ')
+                {
+                    do
+                    {
+                        i++;
+                    }
+                    while(i < (int)wcslen(_wcsFormat) && _wcsFormat[i] == L' ');
+                }
+
+                if(_wcsFormat[i] != L'%')
+                {
+                    wcsData = NULL;
+                    while(i < (int)wcslen(_wcsFormat) && _wcsFormat[i] != L'%')
+                    {
+                        i++;
+                    }
+                }
+                break;
+            }
+        }
+        if(i == (int)wcslen(_wcsFormat))
+        {
+            break;
+        }
+
+        if(iswdigit(_wcsFormat[i]))
+        {
+            nbrOfDigit = wcstol(&_wcsFormat[i], NULL, 10);
+            while(iswdigit(_wcsFormat[i]))
+            {
+                i++;
+            }
+        }
+        else switch(_wcsFormat[i])
+        {
+            case L' ' :
+            case L'\n':
+            case L'\t': i++;
+            break;
+            case L'%' : i++; bIgnoredChars = FALSE;
+            break;
+            case L'*' : bStar = TRUE; i++;
+            break;
+            case L'h' :
+            case L'l' :
+            case L'L' : wcsLLH = _wcsFormat[i]; i++;
+            break;
+            case L'c' :
+            {
+                if(wcsData != NULL && wcsData[0] != L'\0') // If the end of data has not been reached we can get datas.
+                {
+                    wchar_t wcSingleData[2];
+                    wcSingleData[0] = wcsData[0];
+                    wcSingleData[1] = 0;
+
+                    if(!bStar) // If this format is not ignored put the datas found.
+                    {
+                        if(_iIterrator == 0) // Create and initialize the container only the first time.
+                        {
+                            types::String* pS = new types::String(dims,dimsArray);
+                            for(int k = 0 ; k < pS->getSize(); k++)
+                            {
+                                pS->set(k, L"");
+                            }
+                            _pITOut->push_back(pS);
+                        }
+                        (*_pITOut)[j]->getAs<types::String>()->set(_iIterrator, wcSingleData);
+                        iCountDataRead++;
+                    }
+                    wcsData++;
+                }
+                else
+                {
+                    if(_iIterrator == 0 && !bStar && _iNiter == 1)
+                    {
+                        _pITOut->push_back(types::Double::Empty());
+                    }
+                    else
+                    {
+                        return -10;
+                    }
+                }
+                if(!bStar)
+                {
+                    j++;
+                }
+                i++;
+                bIgnoredChars = TRUE;
+                bStar = FALSE;
+            }
+            break;
+            case L's' :
+            {
+                if(wcsData != NULL && wcsData[0] != L'\0')
+                {
+                    wchar_t* wcsSingleData  = NULL;
+                    wchar_t* wcsRes         = NULL;
+                    wchar_t seps[]          = L" \t\n";
+                    int sizeOfCurrentData   = wcslen(wcsData);
+                    wchar_t* wcsTemp        = (wchar_t*)MALLOC((sizeOfCurrentData + 1) * sizeof(wchar_t));
+                    
+                    memcpy(wcsTemp, wcsData, sizeOfCurrentData * sizeof(wchar_t));
+                    wcsTemp[sizeOfCurrentData] = L'\0';
+                    wcsRes = os_wcstok(wcsTemp, seps, &wcsTemp); // the seps[] found is replaced by the '\0' char.
+                    
+                    if(wcsTemp == NULL || wcsTemp[0] == L'\0')
+                    {
+                        wcsData = NULL;
+                    }
+                    else
+                    {
+                        wcsData += (wcslen(wcsData) - wcslen(wcsTemp) -1); // set the pointer on the seps[] and not on the next char.
+                    }
+                    
+                    if(nbrOfDigit) // Get only the numbers of digit indicated in the format. (ex: %2d)
+                    {
+                        wcsSingleData = (wchar_t*)MALLOC(sizeof(wchar_t) * (nbrOfDigit + 1));
+                        memcpy(wcsSingleData, wcsRes, sizeof(wchar_t) * nbrOfDigit);
+                        wcsSingleData[nbrOfDigit] = L'\0';
+                        nbrOfDigit = 0;
+                    }
+                    else // Get all data find.
+                    {
+                        wcsSingleData = wcsRes;
+                    }
+                    
+                    if(!bStar)
+                    {
+                        if(_iIterrator == 0)
+                        {
+                            types::String* pS = new types::String(dims,dimsArray);
+                            for(int k = 0 ; k < pS->getSize(); k++)
+                            {
+                                pS->set(k, L"");
+                            }
+                            _pITOut->push_back(pS);
+                        }
+                        (*_pITOut)[j]->getAs<types::String>()->set(_iIterrator, wcsSingleData);
+                        iCountDataRead++;
+                    }
+
+                    if(nbrOfDigit)
+                    {
+                        FREE(wcsSingleData);
+                    }
+                }
+                else
+                {
+                    if(_iIterrator == 0 && !bStar && _iNiter == 1)
+                    {
+                        _pITOut->push_back(types::Double::Empty());
+                    }
+                    else
+                    {
+                        return -10;
+                    }
+                }
+                if(!bStar)
+                {
+                    j++;
+                }
+                i++;
+                bIgnoredChars = TRUE;
+                bStar = FALSE;
+            }
+            break;
+            case L'[' :
+            {
+                if(wcsData != NULL && wcsData[0] != L'\0')
+                {
+                    wchar_t* wcsInside          = NULL;
+                    wchar_t* wcsCpyFormat       = NULL;
+                    unsigned int iPos           = 0;
+                    wchar_t* wcsSingleData      = NULL;
+                    wchar_t* wcsRes             = NULL;
+                    wchar_t* wscToFind          = NULL;
+                    BOOL bInv                   = FALSE;
+                    
+                    i++;
+                    wcsCpyFormat = (wchar_t*)MALLOC((wcslen(_wcsFormat) - i + 1) * sizeof(wchar_t));
+                    memcpy(wcsCpyFormat, &_wcsFormat[i], (wcslen(_wcsFormat) - i) * sizeof(wchar_t));
+                    wcsCpyFormat[wcslen(_wcsFormat) - i] = L'\0';
+
+                    wcsInside = os_wcstok(wcsCpyFormat,L"]",&wcsCpyFormat);
+                    i += wcslen(wcsInside) + 1; // +1 => ]
+                    
+                    wscToFind = findChars(wcsInside, &bInv);
+                    if(wscToFind == NULL)
+                    {
+                        // MALLOC error
+                        return -10;
+                    }
+
+                    if(bInv)
+                    {
+                        iPos = wcscspn(wcsData, wscToFind);
+                    }
+                    else
+                    {
+                        iPos = wcsspn(wcsData, wscToFind);
+                    }
+
+                    if(iPos == 0)
+                    {
+                        // The string begins with a character which is not in wscToFind
+                        if(_iIterrator == 0 && !bStar && _iNiter == 1)
+                        {
+                            _pITOut->push_back(types::Double::Empty());
+                        }
+                        else
+                        {
+                            return -10;
+                        }
+                    }
+                    else
+                    {
+                        wcsRes = (wchar_t*)MALLOC((iPos + 1) * sizeof(wchar_t));
+                        memcpy(wcsRes, wcsData, iPos * sizeof(wchar_t));
+                        wcsRes[iPos] = '\0';
+
+                        FREE(wcsInside);
+
+                        if(nbrOfDigit)
+                        {
+                            wcsSingleData = (wchar_t*)MALLOC(sizeof(wchar_t) * (nbrOfDigit + 1));
+                            memcpy(wcsSingleData, wcsRes, sizeof(wchar_t) * nbrOfDigit);
+                            wcsSingleData[nbrOfDigit] = L'\0';
+                            wcsData += nbrOfDigit;
+                        }
+                        else
+                        {
+                            wcsSingleData = wcsRes;
+                            wcsData += iPos;
+                        }
+                    }
+
+                    if(!bStar)
+                    {
+                        if(_iIterrator == 0)
+                        {
+                            types::String* pS = new types::String(dims,dimsArray);
+                            for(int k = 0 ; k < pS->getSize(); k++)
+                            {
+                                pS->set(k, L"");
+                            }
+                            _pITOut->push_back(pS);
+                        }
+                        if(wcsSingleData != NULL)
+                        {
+                            (*_pITOut)[j]->getAs<types::String>()->set(_iIterrator, wcsSingleData);
+                            iCountDataRead++;
+                        }
+                    }
+
+                    if(nbrOfDigit)
+                    {
+                        FREE(wcsSingleData);
+                    }
+                }
+                else
+                {
+                    if(_iIterrator == 0 && !bStar && _iNiter == 1)
+                    {
+                        _pITOut->push_back(types::Double::Empty());
+                    }
+                    else
+                    {
+                        return -10;
+                    }
+                }
+                if(!bStar)
+                {
+                    j++;
+                }
+                bIgnoredChars   = TRUE;
+                nbrOfDigit      = 0;
+                bStar           = FALSE;
+            }
+            break;
+            case L'x' :
+            case L'X' : base += 6; // 6 + 2 + 8 = 16 // Compute the base of data to get.
+            case L'u' : if(base == 0) bUnsigned = TRUE;// unsigned int
+            case L'i' :
+            case L'd' : base += 2; // 2 + 8 = 10
+            case L'o' : base += 8; // 8 = 8 :D
+            {
+                if(wcsData != NULL && wcsData[0] != L'\0')
+                {
+                    long int iSingleData = 0;
+                    while(wcsData[0] == L' ')
+                    {
+                        wcsData++;
+                    }
+                    if(nbrOfDigit)
+                    {
+                        wchar_t* number = NULL;
+                        if(wcslen(wcsData) < nbrOfDigit)
+                        {
+                            nbrOfDigit = wcslen(wcsData);
+                        }
+
+                        number = (wchar_t*)MALLOC((nbrOfDigit + 1) * sizeof(wchar_t));
+                        memcpy(number, wcsData, nbrOfDigit * sizeof(wchar_t));
+                        number[nbrOfDigit] = L'\0';
+                        iSingleData = wcstoul(number, &number, base);
+                        if((iSingleData == 0) && (number[0] == wcsData[0]))
+                        {
+                            if(_iIterrator == 0 && !bStar && _iNiter == 1)
+                            {
+                                wcsData = NULL;
+                                _pITOut->push_back(types::Double::Empty());
+                                bStar = TRUE;
+                            }
+                            else
+                            {
+                                return -10;
+                            }
+                        }
+                        if(number == NULL)
+                        {
+                            wcsData += nbrOfDigit;
+                        }
+                        else
+                        {
+                            wcsData += (nbrOfDigit - wcslen(number));
+                        }
+                        nbrOfDigit = 0;
+                    }
+                    else
+                    {
+                        wchar_t temp = wcsData[0];
+                        iSingleData = wcstoul(wcsData,&wcsData,base);
+                        if((iSingleData == 0) && (temp == wcsData[0]))
+                        {
+                            if(_iIterrator == 0 && !bStar && _iNiter == 1)
+                            {
+                                wcsData = NULL;
+                                _pITOut->push_back(types::Double::Empty());
+                                bStar = TRUE;
+                            }
+                            else
+                            {
+                                return -10;
+                            }
+                        }
+                    }
+
+                    if(!bStar)
+                    {
+                        if(_iIterrator == 0)
+                        {
+                            switch(wcsLLH)
+                            {
+                                case L'h' :
+                                {
+                                    if(bUnsigned)
+                                    {
+                                        types::UInt16* pUInt16 = new types::UInt16(dims,dimsArray);
+                                        for(int k = 0; k < pUInt16->getSize(); k++)
+                                        {
+                                            pUInt16->set(k, 0);
+                                        }
+                                        _pITOut->push_back(pUInt16);                                
+                                    }
+                                    else
+                                    {
+                                        types::Int16* pInt16 = new types::Int16(dims,dimsArray);
+                                        for(int k = 0; k < pInt16->getSize(); k++)
+                                        {
+                                            pInt16->set(k, 0);
+                                        }
+                                        _pITOut->push_back(pInt16);
+                                    }
+                                }
+                                break;
+                                case L'l' :
+                                case L'L' :
+                                {                            
+                                    if(bUnsigned)
+                                    {
+                                        types::UInt64* pUInt64 = new types::UInt64(dims,dimsArray);
+                                        for(int k = 0; k < pUInt64->getSize(); k++)
+                                        {
+                                            pUInt64->set(k, 0);
+                                        }
+                                        _pITOut->push_back(pUInt64);
+                                    }
+                                    else
+                                    {
+                                        types::Int64* pInt64 = new types::Int64(dims,dimsArray);
+                                        for(int k = 0; k < pInt64->getSize(); k++)
+                                        {
+                                            pInt64->set(k, 0);
+                                        }
+                                        _pITOut->push_back(pInt64);
+                                    }
+                                }
+                                break;
+                                default :
+                                {
+                                    if(bUnsigned)
+                                    {
+                                        types::UInt32* pUInt32 = new types::UInt32(dims,dimsArray);
+                                        for(int k = 0; k < pUInt32->getSize(); k++)
+                                        {
+                                            pUInt32->set(k, 0);
+                                        }
+                                        _pITOut->push_back(pUInt32);
+                                    }
+                                    else
+                                    {
+                                        types::Int32* pInt32 = new types::Int32(dims,dimsArray);
+                                        for(int k = 0; k < pInt32->getSize(); k++)
+                                        {
+                                            pInt32->set(k, 0);
+                                        }
+                                        _pITOut->push_back(pInt32);
+                                    }
+                                }
+                            }
+                        }
+                        switch(wcsLLH)
+                        {
+                            case L'h' : 
+                                if(bUnsigned)
+                                {
+                                    (*_pITOut)[j]->getAs<types::UInt16>()->set(_iIterrator, static_cast<unsigned short int>(iSingleData));
+                                    iCountDataRead++;
+                                }
+                                else
+                                {
+                                    (*_pITOut)[j]->getAs<types::Int16>()->set(_iIterrator, static_cast<short int>(iSingleData));
+                                    iCountDataRead++;
+                                }
+                            break;
+                            case L'l' :
+                            case L'L' : 
+                                if(bUnsigned)
+                                {
+                                    (*_pITOut)[j]->getAs<types::UInt64>()->set(_iIterrator, iSingleData);
+                                    iCountDataRead++;
+                                }
+                                else
+                                {
+                                    (*_pITOut)[j]->getAs<types::Int64>()->set(_iIterrator, static_cast<long int>(iSingleData));
+                                    iCountDataRead++;
+                                }
+                            break;
+                            default :
+                                if(bUnsigned)
+                                {
+                                    (*_pITOut)[j]->getAs<types::UInt32>()->set(_iIterrator, static_cast<unsigned int>(iSingleData));
+                                    iCountDataRead++;
+                                }
+                                else
+                                {
+                                    (*_pITOut)[j]->getAs<types::Int32>()->set(_iIterrator, static_cast<int>(iSingleData));
+                                    iCountDataRead++;
+                                }
+                        }
+                    }
+                }
+                else
+                {
+                    if(_iIterrator == 0 && !bStar && _iNiter == 1)
+                    {
+                        _pITOut->push_back(types::Double::Empty());
+                    }
+                    else
+                    {
+                        return -10;
+                    }
+                }
+                if(!bStar)
+                {
+                    j++;
+                }
+                wcsLLH          = L' ';
+                bIgnoredChars   = TRUE;
+                bUnsigned       = FALSE;
+                bNegatif        = FALSE;
+                bStar           = FALSE;
+                base            = 0;
+                i++;
+            }
+            break;
+            case L'e' :
+            case L'E' :
+            case L'g' :
+            case L'G' :
+            case L'f' :
+            {
+                if(wcsData != NULL && wcsData[0] != L'\0')
+                {
+                    double dSingleData  = 0;
+                    BOOL bSigne         = FALSE;
+                    while(wcsData[0] == L' ')
+                    {
+                        wcsData++;
+                    }
+                    if(nbrOfDigit)
+                    {
+                        int iSizeRead   = 0;
+                        wchar_t* number = NULL;
+                        wchar_t* next   = NULL;
+                        if(wcslen(wcsData) < nbrOfDigit)
+                        {
+                            nbrOfDigit = wcslen(wcsData);
+                        }
+                        number = (wchar_t*)MALLOC((nbrOfDigit + 1) * sizeof(wchar_t));
+                        memcpy(number, wcsData, nbrOfDigit * sizeof(wchar_t));
+                        number[nbrOfDigit] = L'\0';
+                        dSingleData = wcstod(number, &next);
+                        if(next)
+                        {
+                            iSizeRead = nbrOfDigit - wcslen(next);
+                        }
+                        else
+                        {
+                            iSizeRead = nbrOfDigit;
+                        }
+                        if((dSingleData == 0) && (number[0] == next[0]))
+                        {
+                            if(_iIterrator == 0 && !bStar && _iNiter == 1)
+                            {
+                                wcsData = NULL;
+                                _pITOut->push_back(types::Double::Empty());
+                                bStar = TRUE;
+                            }
+                            else
+                            {
+                                return -10;
+                            }
+                        }
+                        wcsData += iSizeRead;
+                        FREE(number);
+                        nbrOfDigit = 0;
+                    }
+                    else
+                    {
+                        int iLenData = wcslen(wcsData);
+                        dSingleData = wcstod(wcsData,&wcsData);
+                        if((dSingleData == 0) && (iLenData == wcslen(wcsData)))
+                        {
+                            if(_iIterrator == 0 && !bStar && _iNiter == 1)
+                            {
+                                wcsData = NULL;
+                                _pITOut->push_back(types::Double::Empty());
+                                bStar = TRUE;
+                            }
+                            else
+                            {
+                                return -10;
+                            }
+                        }
+                    }
+
+                    if(!bStar)
+                    {
+                        if(_iIterrator == 0)
+                        {
+                            types::Double* pD = new types::Double(dims,dimsArray);
+                            for(int k = 0 ; k < pD->getSize(); k++)
+                            {
+                                pD->set(k, 0);
+                            }
+                            _pITOut->push_back(pD);
+                        }
+                        (*_pITOut)[j]->getAs<types::Double>()->set(_iIterrator, dSingleData);
+                        iCountDataRead++;
+                    }
+                }
+                else
+                {
+                    if(_iIterrator == 0 && !bStar && _iNiter == 1)
+                    {
+                        _pITOut->push_back(types::Double::Empty());
+                    }
+                    else
+                    {
+                        return -10;
+                    }
+                }
+                if(!bStar)
+                {
+                    j++;
+                }
+                i++;
+                bIgnoredChars = TRUE;
+                bStar = FALSE;
+            }
+            break;
+            case L'n' :
+            {
+                double dSingleData = -1;
+                if(_iIterrator == 0 && !bStar)
+                {
+                    types::Double* pD = new types::Double(dims,dimsArray);
+                    for(int k = 0 ; k < pD->getSize(); k++)
+                    {
+                        pD->set(k, 0);
+                    }
+                    _pITOut->push_back(pD);
+                }
+
+                if(wcsData == NULL || wcsData[0] == L'\0')
+                {
+                    dSingleData = (double)sizeOfData;
+                }
+                else
+                {
+                    dSingleData = (double)sizeOfData - (double)wcslen(wcsData);
+                }
+
+                if(!bStar)
+                {
+                    (*_pITOut)[j]->getAs<types::Double>()->set(_iIterrator, dSingleData);
+                    j++;
+                }
+
+                i++;
+                bIgnoredChars = TRUE;
+                bStar = FALSE;
+            }
+            break;
+            default :
+                printf("format read : %c\n",_wcsFormat[i]);
+                return -10;
+        }
+    }
+
+    return iCountDataRead;
+}
+
+wchar_t* findChars(wchar_t* chars, BOOL* _bInv) // ex: "123456789abc" = findChars("1-9abc")
+{
+    unsigned int iIterChars = 0;
+    unsigned int iIterRes   = 0;
+    int iNbr                = 0;
+    int iLen                = 0;
+    wchar_t* wcsRes         = NULL;
+    int* piPos              = NULL;
+
+    piPos = (int*)MALLOC(wcslen(chars) * sizeof(int));
+
+    if(chars[0] == L'^')
+    {
+        *_bInv = TRUE;
+    }
+    else
+    {
+        *_bInv = FALSE;
+    }
+
+    for(iIterChars = 0; iIterChars < wcslen(chars); iIterChars++)
+    {
+        if(chars[iIterChars] == L'-' && iIterChars != 0 && iIterChars != wcslen(chars) - 1)
+        {
+            int iSize = chars[iIterChars + 1] - chars[iIterChars - 1] - 1;
+            if(iSize >= 0)
+            {
+                iLen += iSize;
+                iNbr++;
+                piPos[iIterChars] = 1;
+            }
+            else
+            {
+                piPos[iIterChars] = 0;
+                iLen++;
+            }
+        }
+        else
+        {
+            piPos[iIterChars] = 0;
+            iLen++;
+        }
+    }
+
+    wcsRes = (wchar_t*)MALLOC((iLen + 1)*sizeof(wchar_t));
+
+    for(iIterChars = 0; iIterChars < wcslen(chars); iIterChars++)
+    {
+        if(piPos[iIterChars])
+        {
+            for(int i = 1; i < (chars[iIterChars + 1] - chars[iIterChars - 1]); i++, iIterRes++)
+            {
+                wcsRes[iIterRes] = chars[iIterChars - 1] + i;
+            }
+        }
+        else
+        {
+            wcsRes[iIterRes] = chars[iIterChars];
+            iIterRes++;
+        }
+    }
+    wcsRes[iLen] = L'\0';
+
+    FREE(piPos);
+    return wcsRes;
+}
diff --git a/scilab/modules/fileio/src/cpp/scilab_sscanf.hxx b/scilab/modules/fileio/src/cpp/scilab_sscanf.hxx
new file mode 100644 (file)
index 0000000..c64e572
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2011 - DIGITEO - 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 __SCILAB_SCANF_HXX__
+#define __SCILAB_SCANF_HXX__
+
+#include "dynlib_fileio.h"
+#include "internal.hxx"
+
+int scilab_sscanf(wchar_t* _wcsFormat, wchar_t* _wcsData, int _iIterrator, int iNiter, std::vector<types::InternalType*>* _pITOut);
+
+#endif /* !__SCILAB_SCANF_HXX__ */
diff --git a/scilab/modules/fileio/tests/benchmarks/bench_msscanf.tst b/scilab/modules/fileio/tests/benchmarks/bench_msscanf.tst
new file mode 100644 (file)
index 0000000..e1556f0
--- /dev/null
@@ -0,0 +1,26 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Cedric Delamarre
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+//==============================================================================
+// Benchmark msscanf
+//==============================================================================
+
+// <-- BENCH NB RUN : 10 -->
+NB_VARS = 100;
+NB_LINES = 1000;
+
+string_to_parse =[];
+string_to_parse = strsubst(emptystr(NB_LINES,1)+'A', 'A', strcat(string(1:NB_VARS)," "));
+
+format_to_parse = "" + strcat(strsubst(strcat(string(ones(1,NB_VARS)), " "), "1", "%s")) + "";
+
+//line_to_exec = "[ N," + strcat("v"+string(1:NB_VARS), ",") + "] = msscanf(-1, string_to_parse , format_to_parse );";
+line_to_exec = "res = msscanf(-1, string_to_parse , format_to_parse );";
+
+// <-- BENCH START -->
+execstr(line_to_exec)
+// <-- BENCH END -->
index 578fc4f..4f8b1ec 100644 (file)
@@ -8,11 +8,14 @@
 
 // <-- JVM NOT MANDATORY -->
 
-deff('[n,a,b,c,d,e]=Fscanf(str,f)',['fd=mopen(TMPDIR+''/fscanf.rep'',''w'');';
-       'mputstr(str,fd);mclose(fd);';
-       'fd=mopen(TMPDIR+''/fscanf.rep'',''r'');';
-       '[n,a,b,c,d,e]=mfscanf(fd,f);mclose(fd);']);
-
+function [n,a,b,c,d,e]=Fscanf(str ,f)
+     fd = mopen(TMPDIR + '/fscanf.rep', 'w');
+     mputstr(str, fd);
+     mclose(fd);
+     fd = mopen(TMPDIR + '/fscanf.rep', 'r');
+     [n,a,b,c,d,e] = mfscanf(fd, f);
+     mclose(fd);
+endfunction
 
 //--------------test format %i
 [n,a]=Fscanf('123','%i');
index ae539e2..eca4f4d 100644 (file)
@@ -181,7 +181,7 @@ if n<>1|a<>'poo' then pause,end
 
 //------------- test ignoring arguments 
 [n,a,b]=msscanf('123 4 pipo poo','%*s%s%*s%s');
-//if n<>2|a<>'4'|b<>'poo' then pause,end
+if n<>2|a<>'4'|b<>'poo' then pause,end
 //------------- test composed directives 
 [n,a]=msscanf('123 4','123%le');
 if n<>1|a<>4 then pause,end
@@ -194,7 +194,7 @@ if n<>2|a<>123|b<>456 then pause,end
 [n,a]=msscanf('123 poo','123%le');
 if n<>0 then pause,end
 
-//------------- test end-of-file
+//------------- test end-of-line
 [n,a]=msscanf('123','123%le');
 if n<>-1 then pause,end
 
@@ -206,25 +206,25 @@ A1=strcat(string(A),' ','c');
 F='%d';F=strcat(F(ones(1,n)),' ');
 // all lines read as int we scan a 5x5 matrix 
 A2=msscanf(-1,A1,F);
-if norm(A2-A) > %eps then pause;end 
-// read just 2 lines 
+if norm(A2-A) > %eps then pause;end
+// read just 2 lines
 A2=msscanf(2,A1,F);
-if norm(A2-A(1:2,:)) > %eps then pause;end 
-// explicit columns we scan five columns 
+if norm(A2-A(1:2,:)) > %eps then pause;end
+// explicit columns we scan five columns
 [n,a,b,c,d,e]=msscanf(-1,A1,F);
-if n<>5 then pause;end 
-if norm([a,b,c,d,e]-A) > %eps then pause;end 
-// all lines read as int but we scan only 2 columns 
+if n<>5 then pause;end
+if norm([a,b,c,d,e]-A) > %eps then pause;end
+// all lines read as int but we scan only 2 columns
 A2=msscanf(-1,A1,'%d%d');
-if norm(A2-A(:,1:2)) > %eps then pause;end 
+if norm(A2-A(:,1:2)) > %eps then pause;end
 
 // all lines read as string 
 F='%s';F=strcat(F(ones(1,n)),' ');
 A2=msscanf(-1,A1,F);
-if A2<>string(A) then pause;end 
-// read just 2 lines 
+if A2<>string(A) then pause;end
+// read just 2 lines
 A2=msscanf(2,A1,F);
-if A2<>string(A(1:2,:))  then pause;end 
+if A2<>string(A(1:2,:))  then pause;end
 
 // mixed types read column 1 and 2 as string and others as int
 Fs='%s';Fs=strcat(Fs(ones(1,2)),' ');
index 91bfba3..3bfd8ab 100644 (file)
@@ -31,7 +31,7 @@ typedef struct
     types::InternalType::RealType type;
 }ArgumentPosition;
 
-wchar_t** scilab_sprintf(wchar_t* _pwstName, wchar_t* _pwstInput, types::typed_list &in, ArgumentPosition* _pArgs, int _iArgsCount, int* _piOutputRows);
+OUTPUT_STREAM_IMPEXP wchar_t** scilab_sprintf(wchar_t* _pwstName, wchar_t* _pwstInput, types::typed_list &in, ArgumentPosition* _pArgs, int _iArgsCount, int* _piOutputRows);
 
 
 #endif /* !__SCILAB_SPRINTF_HXX__ */
index 8889097..8190db3 100644 (file)
@@ -26,6 +26,8 @@ extern "C"
 #include "os_wcsdup.h"
 }
 
+#include <stdio.h>
+
 wchar_t** scilab_sprintf(wchar_t* _pwstName, wchar_t* _pwstInput, typed_list &in, ArgumentPosition* _pArgs, int _iArgsCount, int* _piOutputRows)
 {
     wchar_t** pwstOutput        = NULL;
@@ -215,23 +217,50 @@ wchar_t** scilab_sprintf(wchar_t* _pwstName, wchar_t* _pwstInput, typed_list &in
                 else if(_pArgs[i - 1].type == InternalType::RealString)
                 {
                     wchar_t* pwstStr = in[_pArgs[i - 1].iArg]->getAs<types::String>()->get(j, _pArgs[i - 1].iPos);
-
-#ifdef _MSC_VER
-                    swprintf(pwstTemp, bsiz, pToken[i].pwstToken, pwstStr);
-#else
-                    if(pToken[i].bLengthFlag == false)
+                    int posC = wcscspn(pToken[i].pwstToken,L"c");
+                    int posS = wcscspn(pToken[i].pwstToken,L"s");
+                    if(!posS || !posC)
+                    {
+                        return NULL;
+                    }
+                    if(posC < posS)
                     {
-                        //replace %s by %ls to wide char compatibility
-                        wchar_t* pwstToken = (wchar_t*)MALLOC(sizeof(wchar_t) * (wcslen(pToken[i].pwstToken) + 2));
-                        swprintf(pwstToken, wcslen(pToken[i].pwstToken) + 2, pToken[i].pwstToken, "%ls");
-                        swprintf(pwstTemp, bsiz, pwstToken, pwstStr);
-                        FREE(pwstToken);
+                        if(pToken[i].bLengthFlag == false)
+                        {
+                            //replace %c by %lc to wide char compatibility
+                            int sizeTotal = wcslen(pToken[i].pwstToken);
+                            wchar_t* pwstToken = (wchar_t*)MALLOC(sizeof(wchar_t) * (sizeTotal + 2));
+                            wcsncpy(pwstToken, pToken[i].pwstToken, posC);
+                            pwstToken[posC] = L'l';
+                            wcsncpy(&pwstToken[posC + 1], &pToken[i].pwstToken[posC], sizeTotal - posC);
+                            pwstToken[sizeTotal + 1]  = L'\0';
+                            swprintf(pwstTemp, bsiz, pwstToken, pwstStr[0]);
+                            FREE(pwstToken);
+                        }
+                        else
+                        {
+                            swprintf(pwstTemp, bsiz, pToken[i].pwstToken, pwstStr[0]);
+                        }
                     }
-                    else
+                    else //'s'
                     {
-                        swprintf(pwstTemp, bsiz, pToken[i].pwstToken, pwstStr);
+                        if(pToken[i].bLengthFlag == false)
+                        {
+                            //replace %s by %ls to wide char compatibility
+                            int sizeTotal = wcslen(pToken[i].pwstToken);
+                            wchar_t* pwstToken = (wchar_t*)MALLOC(sizeof(wchar_t) * (sizeTotal + 2));
+                            wcsncpy(pwstToken, pToken[i].pwstToken, posS);
+                            pwstToken[posS] = L'l';
+                            wcsncpy(&pwstToken[posS + 1], &pToken[i].pwstToken[posS], sizeTotal - posS);
+                            pwstToken[sizeTotal + 1]  = L'\0';
+                            swprintf(pwstTemp, bsiz, pwstToken, pwstStr);
+                            FREE(pwstToken);
+                        }
+                        else
+                        {
+                            swprintf(pwstTemp, bsiz, pToken[i].pwstToken, pwstStr);
+                        }
                     }
-#endif
                 }
                 else
                 {//impossible but maybe in the futur
index de4b727..03a10e6 100644 (file)
@@ -26,6 +26,7 @@ src/c/stringsCompare.c \
 src/c/isalphanum.c \
 src/c/StringConvert.c \
 src/c/os_wcsdup.c \
+src/c/os_wcstok.c \
 src/c/scistrtostr.c
 
 STRING_FORTRAN_SOURCES =
index bf444d9..3b0761d 100644 (file)
@@ -129,6 +129,7 @@ am__objects_1 = libscistring_algo_la-convstr.lo \
        libscistring_algo_la-isalphanum.lo \
        libscistring_algo_la-StringConvert.lo \
        libscistring_algo_la-os_wcsdup.lo \
+       libscistring_algo_la-os_wcstok.lo \
        libscistring_algo_la-scistrtostr.lo
 am__objects_2 = libscistring_algo_la-stripblanks.lo
 am__objects_3 =
@@ -480,6 +481,7 @@ src/c/stringsCompare.c \
 src/c/isalphanum.c \
 src/c/StringConvert.c \
 src/c/os_wcsdup.c \
+src/c/os_wcstok.c \
 src/c/scistrtostr.c
 
 STRING_FORTRAN_SOURCES = 
@@ -733,6 +735,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscistring_algo_la-isletter.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscistring_algo_la-men_Sutils.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscistring_algo_la-os_wcsdup.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscistring_algo_la-os_wcstok.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscistring_algo_la-partfunction.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscistring_algo_la-pcre_error.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscistring_algo_la-pcre_private.Plo@am__quote@
@@ -936,6 +939,13 @@ libscistring_algo_la-os_wcsdup.lo: src/c/os_wcsdup.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscistring_algo_la_CPPFLAGS) $(CPPFLAGS) $(libscistring_algo_la_CFLAGS) $(CFLAGS) -c -o libscistring_algo_la-os_wcsdup.lo `test -f 'src/c/os_wcsdup.c' || echo '$(srcdir)/'`src/c/os_wcsdup.c
 
+libscistring_algo_la-os_wcstok.lo: src/c/os_wcstok.c
+@am__fastdepCC_TRUE@   $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscistring_algo_la_CPPFLAGS) $(CPPFLAGS) $(libscistring_algo_la_CFLAGS) $(CFLAGS) -MT libscistring_algo_la-os_wcstok.lo -MD -MP -MF $(DEPDIR)/libscistring_algo_la-os_wcstok.Tpo -c -o libscistring_algo_la-os_wcstok.lo `test -f 'src/c/os_wcstok.c' || echo '$(srcdir)/'`src/c/os_wcstok.c
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscistring_algo_la-os_wcstok.Tpo $(DEPDIR)/libscistring_algo_la-os_wcstok.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='src/c/os_wcstok.c' object='libscistring_algo_la-os_wcstok.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscistring_algo_la_CPPFLAGS) $(CPPFLAGS) $(libscistring_algo_la_CFLAGS) $(CFLAGS) -c -o libscistring_algo_la-os_wcstok.lo `test -f 'src/c/os_wcstok.c' || echo '$(srcdir)/'`src/c/os_wcstok.c
+
 libscistring_algo_la-scistrtostr.lo: src/c/scistrtostr.c
 @am__fastdepCC_TRUE@   $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscistring_algo_la_CPPFLAGS) $(CPPFLAGS) $(libscistring_algo_la_CFLAGS) $(CFLAGS) -MT libscistring_algo_la-scistrtostr.lo -MD -MP -MF $(DEPDIR)/libscistring_algo_la-scistrtostr.Tpo -c -o libscistring_algo_la-scistrtostr.lo `test -f 'src/c/scistrtostr.c' || echo '$(srcdir)/'`src/c/scistrtostr.c
 @am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscistring_algo_la-scistrtostr.Tpo $(DEPDIR)/libscistring_algo_la-scistrtostr.Plo
diff --git a/scilab/modules/string/includes/os_wcstok.h b/scilab/modules/string/includes/os_wcstok.h
new file mode 100644 (file)
index 0000000..75e7a7d
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2011 - DIGITEO - Antoine ELIAS
+ *
+ *  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 __OS_WCSTOK_H__
+#define __OS_WCSTOK_H__
+
+#include <wchar.h>
+#include "dynlib_string.h"
+
+
+STRING_IMPEXP wchar_t *os_wcstok(wchar_t *_pwstData, const wchar_t *_pwstDelim, wchar_t** _pswtState);
+
+#endif /* !__OS_WCSDUP_H__ */
diff --git a/scilab/modules/string/src/c/os_wcstok.c b/scilab/modules/string/src/c/os_wcstok.c
new file mode 100644 (file)
index 0000000..e94d882
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) DIGITEO - 2011 - Antoine ELIAS
+ * 
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at    
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "os_wcstok.h"
+
+
+wchar_t *os_wcstok(wchar_t *_pwstData, const wchar_t *_pwstDelim, wchar_t** _pswtState)
+{
+#ifndef _MSC_VER
+    return wcstok(_pwstData, _pwstDelim, _pswtState);
+#else
+    return wcstok(_pwstData, _pwstDelim);
+#endif
+}
index 0411722..54f0bf5 100644 (file)
@@ -262,6 +262,7 @@ lib /DEF:"$(ProjectDir)System_env_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:X64 /O
     <ClCompile Include="isdigit.c" />
     <ClCompile Include="isletter.c" />
     <ClCompile Include="men_Sutils.c" />
+    <ClCompile Include="os_wcstok.c" />
     <ClCompile Include="partfunction.c" />
     <ClCompile Include="pcre_error.c" />
     <ClCompile Include="pcre_private.c" />
@@ -280,6 +281,7 @@ lib /DEF:"$(ProjectDir)System_env_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:X64 /O
     <ClCompile Include="tokens.c" />
   </ItemGroup>
   <ItemGroup>
+    <ClInclude Include="..\..\includes\os_wcstok.h" />
     <ClInclude Include="convstr.h" />
     <ClInclude Include="..\..\includes\cvstr.h" />
     <ClInclude Include="..\..\includes\dynlib_string.h" />
index 544e2f9..f8cb157 100644 (file)
     <ClCompile Include="tokens.c">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="os_wcstok.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="convstr.h">
     <ClInclude Include="tokens.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\includes\os_wcstok.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="LibScilab_Import.def">
index f012c63..184234d 100644 (file)
 #include "MALLOC.h" 
 #include "tokens.h"
 #include "os_wcsdup.h"
+#include "os_wcstok.h"
 
 
-wchar_t *os_wcstok(wchar_t *_pwstData, const wchar_t *_pwstDelim, wchar_t** _pswtState)
-{
-#ifndef _MSC_VER
-    return wcstok(_pwstData, _pwstDelim, _pswtState);
-#else
-    return wcstok(_pwstData, _pwstDelim);
-#endif
-}
-
 /*------------------------------------------------------------------------*/
 wchar_t** stringTokens(wchar_t* str, wchar_t* delim, int* sizeOutputs)
 {