add filesep function 13/1813/4
antoine ELIAS [Mon, 6 Sep 2010 09:42:05 +0000 (11:42 +0200)]
Change-Id: I0f7e4cf74a681d72f9c617e21497968c5ecd76d3

14 files changed:
scilab/configure.ac
scilab/modules/core/includes/machine.h.in
scilab/modules/core/includes/machine.h.vc
scilab/modules/fileio/Makefile.am
scilab/modules/fileio/Makefile.in
scilab/modules/fileio/fileio.vcproj
scilab/modules/fileio/includes/fileio_gw.hxx
scilab/modules/fileio/includes/gw_fileio.h
scilab/modules/fileio/sci_gateway/c/gw_fileio.c
scilab/modules/fileio/sci_gateway/c/sci_filesep.c [deleted file]
scilab/modules/fileio/sci_gateway/cpp/fileio_gw.cpp
scilab/modules/fileio/sci_gateway/cpp/fileio_gw.vcproj
scilab/modules/fileio/sci_gateway/cpp/sci_filesep.cpp [new file with mode: 0644]
scilab/modules/fileio/sci_gateway/cpp/sci_isdir.cpp

index bb89714..194325d 100644 (file)
@@ -1642,6 +1642,11 @@ AH_BOTTOM([
 #endif
 #define DIR_SEPARATOR "/"
 
+#ifdef DIR_SEPARATORW
+          #undef DIR_SEPARATORW
+#endif
+#define DIR_SEPARATORW L"/"
+
 #endif /* MACHINE_H  */
 ])
 
index 38c3c98..ea16eac 100644 (file)
 #endif
 #define DIR_SEPARATOR "/"
 
+#ifdef DIR_SEPARATORW
+          #undef DIR_SEPARATORW
+#endif
+#define DIR_SEPARATORW L"/"
+
 #endif /* MACHINE_H  */
 
index 80b5247..bdf9be9 100644 (file)
@@ -1,8 +1,8 @@
 /** machine.h version for vc++ **/
 /* Copyright INRIA/ENPC */
 
-#ifndef MACHINE_H 
-#define MACHINE_H 
+#ifndef MACHINE_H
+#define MACHINE_H
 
 #include <math.h>
 
@@ -32,7 +32,7 @@
 
 #if defined(USE_SHARP_SIGN)
 #define CNAME(name1,name2) name1##name2
-#else 
+#else
 #define CNAME(name1,name2) name1/**/name2
 #endif
 
@@ -41,7 +41,7 @@
 #if defined(USE_SHARP_SIGN)
 #define C2F(name) name##_
 #define F2C(name) name##_
-#else 
+#else
 #define C2F(name) name/**/_
 #define F2C(name) name/**/_
 #endif
@@ -63,9 +63,9 @@
 #define getwd(x) getcwd(x,1024) /* you must define char x[1024] */
 #endif
 
-/* 
+/*
    Define integer C type which must fit Fortran integer
-   For Scilab to work, the rule is: 
+   For Scilab to work, the rule is:
           size of Fortran double precision = 2 * size of Fortran integer
 
    At the present time, we suppose:
@@ -81,6 +81,7 @@
 
 /* DIR_SEPARATOR : Under Windows by default is \ */
 #define DIR_SEPARATOR "\\"
+#define DIR_SEPARATORW L"\\"
 
 #define HAVE_LIBINTL_H
 
index b85e428..7d3f4d4 100644 (file)
@@ -62,7 +62,6 @@ sci_gateway/c/sci_getdrives.c \
 sci_gateway/c/sci_fullpath.c \
 sci_gateway/c/sci_deletefile.c \
 sci_gateway/c/sci_pathsep.c \
-sci_gateway/c/sci_filesep.c \
 sci_gateway/c/sci_getshortpathname.c \
 sci_gateway/c/sci_getlongpathname.c \
 sci_gateway/c/sci_fileext.c \
@@ -96,7 +95,8 @@ GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_mputl.cpp \
        sci_gateway/cpp/sci_mgetl.cpp \
        sci_gateway/cpp/sci_pathconvert.cpp \
-       sci_gateway/cpp/sci_isdir.cpp
+       sci_gateway/cpp/sci_isdir.cpp \
+       sci_gateway/cpp/sci_filesep.cpp
 
 FILEIO_CPP_SOURCES = \
        src/cpp/expandPathVariable.cpp \
index c1c0310..1745725 100644 (file)
@@ -159,7 +159,7 @@ am__objects_3 = libscifileio_la-gw_fileio.lo \
        libscifileio_la-sci_getdrives.lo \
        libscifileio_la-sci_fullpath.lo \
        libscifileio_la-sci_deletefile.lo \
-       libscifileio_la-sci_pathsep.lo libscifileio_la-sci_filesep.lo \
+       libscifileio_la-sci_pathsep.lo \
        libscifileio_la-sci_getshortpathname.lo \
        libscifileio_la-sci_getlongpathname.lo \
        libscifileio_la-sci_fileext.lo \
@@ -181,7 +181,7 @@ am__objects_4 = libscifileio_la-fileio_gw.lo \
        libscifileio_la-sci_mget.lo libscifileio_la-sci_mput.lo \
        libscifileio_la-sci_mputl.lo libscifileio_la-sci_mgetl.lo \
        libscifileio_la-sci_pathconvert.lo \
-       libscifileio_la-sci_isdir.lo
+       libscifileio_la-sci_isdir.lo libscifileio_la-sci_filesep.lo
 am_libscifileio_la_OBJECTS = $(am__objects_1) $(am__objects_2) \
        $(am__objects_3) $(am__objects_4)
 libscifileio_la_OBJECTS = $(am_libscifileio_la_OBJECTS)
@@ -525,7 +525,6 @@ sci_gateway/c/sci_getdrives.c \
 sci_gateway/c/sci_fullpath.c \
 sci_gateway/c/sci_deletefile.c \
 sci_gateway/c/sci_pathsep.c \
-sci_gateway/c/sci_filesep.c \
 sci_gateway/c/sci_getshortpathname.c \
 sci_gateway/c/sci_getlongpathname.c \
 sci_gateway/c/sci_fileext.c \
@@ -559,7 +558,8 @@ GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_mputl.cpp \
        sci_gateway/cpp/sci_mgetl.cpp \
        sci_gateway/cpp/sci_pathconvert.cpp \
-       sci_gateway/cpp/sci_isdir.cpp
+       sci_gateway/cpp/sci_isdir.cpp \
+       sci_gateway/cpp/sci_filesep.cpp
 
 FILEIO_CPP_SOURCES = \
        src/cpp/expandPathVariable.cpp \
@@ -1277,13 +1277,6 @@ libscifileio_la-sci_pathsep.lo: sci_gateway/c/sci_pathsep.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-sci_pathsep.lo `test -f 'sci_gateway/c/sci_pathsep.c' || echo '$(srcdir)/'`sci_gateway/c/sci_pathsep.c
 
-libscifileio_la-sci_filesep.lo: sci_gateway/c/sci_filesep.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_filesep.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-sci_filesep.Tpo -c -o libscifileio_la-sci_filesep.lo `test -f 'sci_gateway/c/sci_filesep.c' || echo '$(srcdir)/'`sci_gateway/c/sci_filesep.c
-@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscifileio_la-sci_filesep.Tpo $(DEPDIR)/libscifileio_la-sci_filesep.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='sci_gateway/c/sci_filesep.c' object='libscifileio_la-sci_filesep.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_filesep.lo `test -f 'sci_gateway/c/sci_filesep.c' || echo '$(srcdir)/'`sci_gateway/c/sci_filesep.c
-
 libscifileio_la-sci_getshortpathname.lo: sci_gateway/c/sci_getshortpathname.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_getshortpathname.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-sci_getshortpathname.Tpo -c -o libscifileio_la-sci_getshortpathname.lo `test -f 'sci_gateway/c/sci_getshortpathname.c' || echo '$(srcdir)/'`sci_gateway/c/sci_getshortpathname.c
 @am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscifileio_la-sci_getshortpathname.Tpo $(DEPDIR)/libscifileio_la-sci_getshortpathname.Plo
@@ -1585,6 +1578,13 @@ libscifileio_la-sci_isdir.lo: sci_gateway/cpp/sci_isdir.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_isdir.lo `test -f 'sci_gateway/cpp/sci_isdir.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_isdir.cpp
 
+libscifileio_la-sci_filesep.lo: sci_gateway/cpp/sci_filesep.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_filesep.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-sci_filesep.Tpo -c -o libscifileio_la-sci_filesep.lo `test -f 'sci_gateway/cpp/sci_filesep.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_filesep.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscifileio_la-sci_filesep.Tpo $(DEPDIR)/libscifileio_la-sci_filesep.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_filesep.cpp' object='libscifileio_la-sci_filesep.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_filesep.lo `test -f 'sci_gateway/cpp/sci_filesep.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_filesep.cpp
+
 mostlyclean-libtool:
        -rm -f *.lo
 
index 07ae032..d424971 100644 (file)
                                >
                        </File>
                        <File
-                               RelativePath=".\sci_gateway\c\sci_filesep.c"
-                               >
-                       </File>
-                       <File
                                RelativePath=".\sci_gateway\c\sci_findfiles.c"
                                >
                        </File>
index 4371d11..ccd0996 100644 (file)
@@ -44,5 +44,6 @@ CPP_GATEWAY_PROTOTYPE(sci_mputl);
 CPP_GATEWAY_PROTOTYPE(sci_mgetl);
 CPP_GATEWAY_PROTOTYPE(sci_pathconvert);
 CPP_GATEWAY_PROTOTYPE(sci_isdir);
+CPP_GATEWAY_PROTOTYPE(sci_filesep);
 
 #endif /* !__FILEIO_GW_HXX__ */
index b12cc89..7b346f3 100644 (file)
@@ -36,7 +36,6 @@ FILEIO_IMPEXP int sci_getdrives(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_fullpath(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_deletefile(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_pathsep(char *fname,unsigned long fname_len);
-FILEIO_IMPEXP int sci_filesep(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_getlongpathname(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_getshortpathname(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_fileext(char *fname,unsigned long fname_len);
index db99952..41e9638 100644 (file)
@@ -42,7 +42,7 @@ static gw_generic_table Tab[]={
        {sci_fullpath,"fullpath"},
        {sci_deletefile,"deletefile"},
        {sci_pathsep,"pathsep"},
-       {sci_filesep,"filesep"},
+       {NULL, ""}, //filesep
        {sci_getlongpathname,"getlongpathname"},
        {sci_getshortpathname,"getshortpathname"},
        {sci_fileext,"fileext"},
diff --git a/scilab/modules/fileio/sci_gateway/c/sci_filesep.c b/scilab/modules/fileio/sci_gateway/c/sci_filesep.c
deleted file mode 100644 (file)
index cc37a2b..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2007 - INRIA - 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 "gw_fileio.h"
-#include "stack-c.h"
-#include "MALLOC.h"
-#include "Scierror.h"
-#include "os_strdup.h"
-/*--------------------------------------------------------------------------*/
-int sci_filesep(char *fname,unsigned long fname_len)
-{
-       static int n1,m1;
-       char *separator = NULL;
-
-       CheckRhs(0,0);
-       CheckLhs(1,1);
-
-       separator = os_strdup(DIR_SEPARATOR);
-
-       n1 = 1;
-       CreateVarFromPtr(Rhs+1,STRING_DATATYPE,(m1=(int)strlen(separator), &m1),&n1,&separator);
-       LhsVar(1)=Rhs+1;
-       C2F(putlhsvar)();
-
-       if (separator) {FREE(separator);separator=NULL;}
-
-       return 0;
-}
-/*--------------------------------------------------------------------------*/
-
index c3644ab..bc0d275 100644 (file)
@@ -33,5 +33,6 @@ bool FileioModule::Load()
     symbol::Context::getInstance()->AddFunction(Function::createFunction(L"mgetl", &sci_mgetl, MODULE_NAME));
     symbol::Context::getInstance()->AddFunction(Function::createFunction(L"pathconvert", &sci_pathconvert, MODULE_NAME));
     symbol::Context::getInstance()->AddFunction(Function::createFunction(L"isdir", &sci_isdir, MODULE_NAME));
+    symbol::Context::getInstance()->AddFunction(Function::createFunction(L"filesep", &sci_filesep, MODULE_NAME));
     return true;
 }
index 75da90f..13ae450 100644 (file)
                                >
                        </File>
                        <File
+                               RelativePath=".\sci_filesep.cpp"
+                               >
+                       </File>
+                       <File
                                RelativePath=".\sci_isdir.cpp"
                                >
                        </File>
diff --git a/scilab/modules/fileio/sci_gateway/cpp/sci_filesep.cpp b/scilab/modules/fileio/sci_gateway/cpp/sci_filesep.cpp
new file mode 100644 (file)
index 0000000..e7f8491
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2007 - INRIA - Allan CORNET
+ * Copyright (C) 2010 - 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
+ *
+ */
+/*--------------------------------------------------------------------------*/
+#include "alltypes.hxx"
+#include "funcmanager.hxx"
+#include "filemanager.hxx"
+#include "fileio_gw.hxx"
+
+extern "C"
+{
+/* DIR_SEPARATORW */
+#include "machine.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "os_wcsicmp.h"
+}
+
+/*--------------------------------------------------------------------------*/
+Function::ReturnValue sci_filesep(typed_list &in, int _iRetCount, typed_list &out)
+{
+    if(in.size() != 0)
+    {
+        ScierrorW(999, _W("%ls: Wrong number of input arguments: %d expected.\n"), L"filesep" , 0);
+        return Function::Error;
+    }
+
+    if(_iRetCount != 1 && _iRetCount != -1)
+    {
+        ScierrorW(78,_W("%ls: Wrong number of output argument(s): %d expected.\n"), L"filesep", 1);
+        return Function::Error;
+    }
+
+    String* pS = new String(DIR_SEPARATORW);
+    out.push_back(pS);
+    return Function::OK;
+    //static int n1,m1;
+       //char *separator = NULL;
+
+       //CheckRhs(0,0);
+       //CheckLhs(1,1);
+
+       //separator = os_strdup(DIR_SEPARATOR);
+
+       //n1 = 1;
+       //CreateVarFromPtr(Rhs+1,STRING_DATATYPE,(m1=(int)strlen(separator), &m1),&n1,&separator);
+       //LhsVar(1)=Rhs+1;
+       //C2F(putlhsvar)();
+
+       //if (separator) {FREE(separator);separator=NULL;}
+
+       //return 0;
+}
+/*--------------------------------------------------------------------------*/
+
index 01b01eb..7e68725 100644 (file)
@@ -46,7 +46,7 @@ Function::ReturnValue sci_isdir(typed_list &in, int _iRetCount, typed_list &out)
 
     if(in[0]->isString() == false)
     {
-        ScierrorW(999, _W("%ls: Wrong type for input argument #%d: Matrix of strings expected.\n"), L"pathconvert", 1);
+        ScierrorW(999, _W("%ls: Wrong type for input argument #%d: Matrix of strings expected.\n"), L"isdir", 1);
         return Function::Error;
     }