use strdup
Allan CORNET [Fri, 19 Jun 2009 12:13:45 +0000 (14:13 +0200)]
40 files changed:
scilab/modules/call_scilab/src/c/SendScilabJobs.c
scilab/modules/core/sci_gateway/c/sci_getscilabmode.c
scilab/modules/core/sci_gateway/c/sci_warning.c
scilab/modules/core/src/c/inisci-c.c
scilab/modules/dynamic_link/sci_gateway/c/sci_link.c
scilab/modules/dynamic_link/src/c/dynamic_link.vcproj
scilab/modules/dynamic_link/src/c/scilab_windows_Import.def [new file with mode: 0644]
scilab/modules/fftw/fftw.vcproj
scilab/modules/fftw/sci_gateway/c/sci_fftw_flags.c
scilab/modules/fftw/scilab_windows_Import.def [new file with mode: 0644]
scilab/modules/fftw/src/c/fftwlibname.c
scilab/modules/fileio/sci_gateway/c/sci_filesep.c
scilab/modules/fileio/sci_gateway/c/sci_fullpath.c
scilab/modules/fileio/sci_gateway/c/sci_isdir.c
scilab/modules/fileio/sci_gateway/c/sci_newest.c
scilab/modules/fileio/src/c/URIFileToFilename.c
scilab/modules/fileio/src/c/isdir.c
scilab/modules/graphics/src/c/Format.c
scilab/modules/graphics/src/c/StringMatrix.c
scilab/modules/graphics/src/c/getHandleProperty/SetHashTable.c
scilab/modules/graphics/src/c/getHandleProperty/setGetHashTable.c
scilab/modules/gui/sci_gateway/c/sci_ClipBoard.c
scilab/modules/gui/src/c/buildMainWindowTitle.c
scilab/modules/gui/src/c/getMainWindowTitle.c
scilab/modules/history_manager/sci_gateway/c/sci_historymanager.c
scilab/modules/history_manager/src/cpp/HistoryManager.cpp
scilab/modules/history_manager/src/cpp/HistorySearch.cpp
scilab/modules/javasci/Javasci.vcproj
scilab/modules/javasci/src/c/javasci_globals.c
scilab/modules/jvm/src/c/system_getproperty.c
scilab/modules/jvm/src/c/system_setproperty.c
scilab/modules/metanet/src/c/hashtable_metanet.c
scilab/modules/metanet/src/c/loadg.c
scilab/modules/metanet/src/c/metanet.vcproj
scilab/modules/metanet/src/c/scilab_windows_Import.def [new file with mode: 0644]
scilab/modules/sound/sci_gateway/c/sci_beep.c
scilab/modules/sound/scilab_windows_Import.def [new file with mode: 0644]
scilab/modules/sound/sound.vcproj
scilab/modules/string/sci_gateway/c/sci_grep.c
scilab/modules/windows_tools/src/c/TextToPrint.c

index 54b17f0..823be6d 100644 (file)
@@ -10,6 +10,7 @@
  *
  */
 #include <stdio.h>
+#include <string.h>
 #include "CallScilab.h"
 #include "MALLOC.h"
 #include "scirun.h"
@@ -37,16 +38,14 @@ int SendScilabJob(char *job)
        static char ScirunCommand[] = "Err=execstr(TMP_EXEC_STRING,\"errcatch\",\"n\");quit;";
        static char ClearTmpVariables[] = "clear TMP_EXEC_STRING;clear Err;quit;";
        
-       lencommand = (int)strlen(job);
-       command = MALLOC(sizeof(char)*(lencommand+1));
+       command = strdup(job);
+       lencommand = (int)strlen(command);
 
        if (command)
        {
                /* clear prev. Err , TMP_EXEC_STRING scilab variables */
                C2F(scirun)(ClearTmpVariables,(long int)strlen(ClearTmpVariables));
 
-               /* @TODO: potential security issue. check the size */
-               strcpy(command,job);
                SetLastJob(command);
                /* Creation of a temp variable in Scilab which contains the command */
                if (!C2F(cwritechain)("TMP_EXEC_STRING",&lencommand,(char*)command,(int)strlen("TMP_EXEC_STRING"),(int)strlen(command)) )
index 5e02217..944af66 100644 (file)
 #include "stack-c.h"
 #include "MALLOC.h"
 #include "scilabmode.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
 /*--------------------------------------------------------------------------*/
 int C2F(sci_getscilabmode)(char *fname,unsigned long fname_len)
 {
-       static int n1,m1;
-       char *output=NULL ;
+       int n1 = 0, m1 = 0;
+       char *output = NULL ;
 
        Rhs=Max(Rhs,0);
        CheckRhs(0,0) ;
        CheckLhs(1,1) ;
 
-       output=(char*)MALLOC((strlen("NWNI")+1)*sizeof(char));
-
        switch (getScilabMode())
        {
                case SCILAB_API: default :
-                       strcpy(output,"API");
+                       output = strdup("API");
                break;
                case SCILAB_STD:
-                       strcpy(output,"STD");
+                       output = strdup("STD");
                break;
                case SCILAB_NW:
-                       strcpy(output,"NW");
+                       output = strdup("NW");
                break;
                case SCILAB_NWNI:
-                       strcpy(output,"NWNI");
+                       output = strdup("NWNI");
                break;
        }
 
@@ -48,8 +49,6 @@ int C2F(sci_getscilabmode)(char *fname,unsigned long fname_len)
 
        LhsVar(1) = Rhs+1;
        C2F(putlhsvar)();
-
-       //      if (output) {FREE(output);output=NULL;}
        return 0;
 }
 /*--------------------------------------------------------------------------*/
index d02a6c3..0534fc3 100644 (file)
@@ -19,6 +19,9 @@
 #include "Scierror.h"
 #include "localization.h"
 #include "freeArrayOfString.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
 /*--------------------------------------------------------------------------*/
 int C2F(sci_warning)(char *fname,unsigned long fname_len)
 {
@@ -51,17 +54,15 @@ int C2F(sci_warning)(char *fname,unsigned long fname_len)
                        {
                                if (strcmp(Input_Strings[0],"query") == 0)
                                {
-                                       char *Output=NULL;
-
-                                       Output=(char*)MALLOC(4*sizeof(char));
+                                       char *Output = NULL;
 
                                        if (getWarningMode())
                                        {
-                                               strcpy(Output,"on");
+                                               Output = strdup("on");
                                        }
                                        else
                                        {
-                                               strcpy(Output,"off");
+                                               Output = strdup("off");
                                        }
 
                                        n1=1;
index cce6cd0..dcb2651 100644 (file)
@@ -71,7 +71,7 @@ int SetSci(void)
 {
        int ierr,iflag=0;
        int lbuf=PATH_MAX;
-       char *buf = MALLOC(PATH_MAX*sizeof(char));
+       char *buf = (char*)MALLOC(PATH_MAX*sizeof(char));
        if (buf)
        {
                C2F(getenvc)(&ierr,"SCI",buf,&lbuf,&iflag);
index ac17c5f..6c5b9c3 100644 (file)
@@ -20,6 +20,9 @@
 #include "localization.h"
 #include "dl_genErrorMessage.h"
 #include "freeArrayOfString.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
 /*-----------------------------------------------------------------------------------*/
 static int linkNoRhs(void);
 static int linkOneRhsShow(void);
@@ -73,8 +76,7 @@ int sci_link(char *fname,unsigned long fname_len)
 
                                if ( (m1 == 1) && (n1 == 1) )
                                {
-                                       SharedLibraryName =(char*)MALLOC(sizeof(char)*(strlen(strings[0])+1));
-                                       strcpy(SharedLibraryName,strings[0]);
+                                       SharedLibraryName = strdup(strings[0]);
                                        freeArrayOfString(strings, m1*n1);
                                }
                                else
@@ -137,8 +139,7 @@ int sci_link(char *fname,unsigned long fname_len)
                }
                else
                {
-                       param3flag = (char*)MALLOC(sizeof(char)*( strlen( "f" )+1 ) );
-                       strcpy(param3flag,"f");
+                       param3flag = strdup("f");
                }
 
                if (strcmp("f",param3flag)==0) fflag = TRUE;
index 726f512..abdfa62 100644 (file)
@@ -44,7 +44,7 @@
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               AdditionalIncludeDirectories="../../includes;../../src/c;../../../../libs/MALLOC/includes;../../../../libs/dynamiclibrary/includes;../../../output_stream/includes;../../../localization/includes;../../../io/includes;../../../core/includes;../../../fileio/includes;../../../../libs/hashtable;../../../../libs/intl"
+                               AdditionalIncludeDirectories="../../includes;../../src/c;../../../../libs/MALLOC/includes;../../../../libs/dynamiclibrary/includes;../../../output_stream/includes;../../../windows_tools/includes;../../../localization/includes;../../../io/includes;../../../core/includes;../../../fileio/includes;../../../../libs/hashtable;../../../../libs/intl"
                                PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;DYNAMIC_LINK_EXPORTS"
                                MinimalRebuild="true"
                                BasicRuntimeChecks="0"
                        <Tool
                                Name="VCPreLinkEventTool"
                                Description="Make dependencies"
-                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)dynamic_link_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)dynamic_link_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Io_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)Io.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n dynamic_link.dll %%f &gt;nul&#x0D;&#x0A;copy *.def dynamic_linktmp.def &gt;nul&#x0D;&#x0A;copy ..\dynamic_link_header.def+dynamic_linktmp.def  ..\dynamic_link.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
+                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)dynamic_link_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)dynamic_link_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Io_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)Io.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Scilab_Windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)Scilab_windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n dynamic_link.dll %%f &gt;nul&#x0D;&#x0A;copy *.def dynamic_linktmp.def &gt;nul&#x0D;&#x0A;copy ..\dynamic_link_header.def+dynamic_linktmp.def  ..\dynamic_link.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="LibScilab.lib dynamic_link_f.lib io.lib"
+                               AdditionalDependencies="LibScilab.lib dynamic_link_f.lib io.lib scilab_windows.lib"
                                OutputFile="../../../../bin/$(ProjectName).dll"
                                LinkIncremental="1"
                                ModuleDefinitionFile="dynamic_link.def"
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               AdditionalIncludeDirectories="../../includes;../../src/c;../../../../libs/MALLOC/includes;../../../../libs/dynamiclibrary/includes;../../../output_stream/includes;../../../localization/includes;../../../io/includes;../../../core/includes;../../../fileio/includes;../../../../libs/hashtable;../../../../libs/intl"
+                               AdditionalIncludeDirectories="../../includes;../../src/c;../../../../libs/MALLOC/includes;../../../../libs/dynamiclibrary/includes;../../../output_stream/includes;../../../windows_tools/includes;../../../localization/includes;../../../io/includes;../../../core/includes;../../../fileio/includes;../../../../libs/hashtable;../../../../libs/intl"
                                PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;DYNAMIC_LINK_EXPORTS"
                                MinimalRebuild="true"
                                BasicRuntimeChecks="0"
                        <Tool
                                Name="VCPreLinkEventTool"
                                Description="Make dependencies"
-                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)dynamic_link_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)dynamic_link_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Io_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)Io.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n dynamic_link.dll %%f &gt;nul&#x0D;&#x0A;copy *.def dynamic_linktmp.def &gt;nul&#x0D;&#x0A;copy ..\dynamic_link_header.def+dynamic_linktmp.def  ..\dynamic_link.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
+                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)dynamic_link_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)dynamic_link_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Io_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)Io.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Scilab_Windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)Scilab_windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n dynamic_link.dll %%f &gt;nul&#x0D;&#x0A;copy *.def dynamic_linktmp.def &gt;nul&#x0D;&#x0A;copy ..\dynamic_link_header.def+dynamic_linktmp.def  ..\dynamic_link.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="LibScilab.lib dynamic_link_f.lib io.lib"
+                               AdditionalDependencies="LibScilab.lib dynamic_link_f.lib io.lib scilab_windows.lib"
                                OutputFile="../../../../bin/$(ProjectName).dll"
                                LinkIncremental="1"
                                ModuleDefinitionFile="dynamic_link.def"
                                InlineFunctionExpansion="1"
                                FavorSizeOrSpeed="1"
                                WholeProgramOptimization="false"
-                               AdditionalIncludeDirectories="../../includes;../../src/c;../../../../libs/MALLOC/includes;../../../../libs/dynamiclibrary/includes;../../../output_stream/includes;../../../localization/includes;../../../io/includes;../../../core/includes;../../../fileio/includes;../../../../libs/hashtable;../../../../libs/intl"
+                               AdditionalIncludeDirectories="../../includes;../../src/c;../../../../libs/MALLOC/includes;../../../../libs/dynamiclibrary/includes;../../../output_stream/includes;../../../windows_tools/includes;../../../localization/includes;../../../io/includes;../../../core/includes;../../../fileio/includes;../../../../libs/hashtable;../../../../libs/intl"
                                PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;DYNAMIC_LINK_EXPORTS"
                                StringPooling="true"
                                RuntimeLibrary="2"
                        <Tool
                                Name="VCPreLinkEventTool"
                                Description="Make dependencies"
-                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)dynamic_link_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)dynamic_link_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Io_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)Io.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n dynamic_link.dll %%f &gt;nul&#x0D;&#x0A;copy *.def dynamic_linktmp.def &gt;nul&#x0D;&#x0A;copy ..\dynamic_link_header.def+dynamic_linktmp.def  ..\dynamic_link.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
+                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)dynamic_link_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)dynamic_link_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Io_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)Io.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Scilab_Windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)Scilab_windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n dynamic_link.dll %%f &gt;nul&#x0D;&#x0A;copy *.def dynamic_linktmp.def &gt;nul&#x0D;&#x0A;copy ..\dynamic_link_header.def+dynamic_linktmp.def  ..\dynamic_link.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="LibScilab.lib dynamic_link_f.lib io.lib"
+                               AdditionalDependencies="LibScilab.lib dynamic_link_f.lib io.lib scilab_windows.lib"
                                OutputFile="../../../../bin/$(ProjectName).dll"
                                LinkIncremental="1"
                                ModuleDefinitionFile="dynamic_link.def"
                                InlineFunctionExpansion="1"
                                FavorSizeOrSpeed="1"
                                WholeProgramOptimization="false"
-                               AdditionalIncludeDirectories="../../includes;../../src/c;../../../../libs/MALLOC/includes;../../../../libs/dynamiclibrary/includes;../../../output_stream/includes;../../../localization/includes;../../../io/includes;../../../core/includes;../../../fileio/includes;../../../../libs/hashtable;../../../../libs/intl"
+                               AdditionalIncludeDirectories="../../includes;../../src/c;../../../../libs/MALLOC/includes;../../../../libs/dynamiclibrary/includes;../../../output_stream/includes;../../../windows_tools/includes;../../../localization/includes;../../../io/includes;../../../core/includes;../../../fileio/includes;../../../../libs/hashtable;../../../../libs/intl"
                                PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;DYNAMIC_LINK_EXPORTS"
                                StringPooling="true"
                                RuntimeLibrary="2"
                        <Tool
                                Name="VCPreLinkEventTool"
                                Description="Make dependencies"
-                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)dynamic_link_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)dynamic_link_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Io_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)Io.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n dynamic_link.dll %%f &gt;nul&#x0D;&#x0A;copy *.def dynamic_linktmp.def &gt;nul&#x0D;&#x0A;copy ..\dynamic_link_header.def+dynamic_linktmp.def  ..\dynamic_link.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
+                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)dynamic_link_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)dynamic_link_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Io_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)Io.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Scilab_Windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)Scilab_windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n dynamic_link.dll %%f &gt;nul&#x0D;&#x0A;copy *.def dynamic_linktmp.def &gt;nul&#x0D;&#x0A;copy ..\dynamic_link_header.def+dynamic_linktmp.def  ..\dynamic_link.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="LibScilab.lib dynamic_link_f.lib io.lib"
+                               AdditionalDependencies="LibScilab.lib dynamic_link_f.lib io.lib scilab_windows.lib"
                                OutputFile="../../../../bin/$(ProjectName).dll"
                                LinkIncremental="1"
                                ModuleDefinitionFile="dynamic_link.def"
                                RelativePath=".\LibScilab_Import.def"
                                >
                        </File>
+                       <File
+                               RelativePath=".\scilab_windows_Import.def"
+                               >
+                       </File>
                </Filter>
                <File
                        RelativePath="..\..\dynamic_link.iss"
diff --git a/scilab/modules/dynamic_link/src/c/scilab_windows_Import.def b/scilab/modules/dynamic_link/src/c/scilab_windows_Import.def
new file mode 100644 (file)
index 0000000..05c63be
--- /dev/null
@@ -0,0 +1,8 @@
+LIBRARY    scilab_windows.dll
+
+
+EXPORTS
+; --------------------------------------- 
+; scilab_windows
+; --------------------------------------- 
+ strdup_windows
index f9afd11..4ef79ca 100644 (file)
@@ -44,7 +44,7 @@
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               AdditionalIncludeDirectories="includes;src/c;../core/includes;../fileio/includes;../output_stream/includes;../localization/includes;../../libs/MALLOC/includes;../../libs/intl;../../libs/dynamiclibrary/includes"
+                               AdditionalIncludeDirectories="includes;src/c;../core/includes;../fileio/includes;../output_stream/includes;../windows_tools/includes;../localization/includes;../../libs/MALLOC/includes;../../libs/intl;../../libs/dynamiclibrary/includes"
                                PreprocessorDefinitions="FORDLL;_DEBUG;_WINDOWS;_USRDLL;SOUND_EXPORTS;_CRT_SECURE_NO_DEPRECATE"
                                MinimalRebuild="true"
                                BasicRuntimeChecks="0"
                        <Tool
                                Name="VCPreLinkEventTool"
                                Description="Make dependencies"
-                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\bin\dumpexts -o %%~nf.def -n fftw.dll %%f &gt;nul&#x0D;&#x0A;copy *.def fftwtmp.def &gt;nul&#x0D;&#x0A;copy ..\fftw_header.def+fftwtmp.def  ..\fftw.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
+                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Scilab_Windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)Scilab_Windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\bin\dumpexts -o %%~nf.def -n fftw.dll %%f &gt;nul&#x0D;&#x0A;copy *.def fftwtmp.def &gt;nul&#x0D;&#x0A;copy ..\fftw_header.def+fftwtmp.def  ..\fftw.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="LibScilab.lib"
+                               AdditionalDependencies="LibScilab.lib scilab_windows.lib"
                                OutputFile="../../bin/$(ProjectName).dll"
                                LinkIncremental="1"
                                ModuleDefinitionFile="fftw.def"
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               AdditionalIncludeDirectories="includes;src/c;../core/includes;../fileio/includes;../output_stream/includes;../localization/includes;../../libs/MALLOC/includes;../../libs/intl;../../libs/dynamiclibrary/includes"
+                               AdditionalIncludeDirectories="includes;src/c;../core/includes;../fileio/includes;../output_stream/includes;../windows_tools/includes;../localization/includes;../../libs/MALLOC/includes;../../libs/intl;../../libs/dynamiclibrary/includes"
                                PreprocessorDefinitions="FORDLL;_DEBUG;_WINDOWS;_USRDLL;SOUND_EXPORTS;_CRT_SECURE_NO_DEPRECATE"
                                MinimalRebuild="true"
                                BasicRuntimeChecks="0"
                        <Tool
                                Name="VCPreLinkEventTool"
                                Description="Make dependencies"
-                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\bin\dumpexts -o %%~nf.def -n fftw.dll %%f &gt;nul&#x0D;&#x0A;copy *.def fftwtmp.def &gt;nul&#x0D;&#x0A;copy ..\fftw_header.def+fftwtmp.def  ..\fftw.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
+                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Scilab_Windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)Scilab_Windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\bin\dumpexts -o %%~nf.def -n fftw.dll %%f &gt;nul&#x0D;&#x0A;copy *.def fftwtmp.def &gt;nul&#x0D;&#x0A;copy ..\fftw_header.def+fftwtmp.def  ..\fftw.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="LibScilab.lib"
+                               AdditionalDependencies="LibScilab.lib scilab_windows.lib"
                                OutputFile="../../bin/$(ProjectName).dll"
                                LinkIncremental="1"
                                ModuleDefinitionFile="fftw.def"
                                InlineFunctionExpansion="1"
                                FavorSizeOrSpeed="1"
                                WholeProgramOptimization="false"
-                               AdditionalIncludeDirectories="includes;src/c;../core/includes;../fileio/includes;../output_stream/includes;../localization/includes;../../libs/MALLOC/includes;../../libs/intl;../../libs/dynamiclibrary/includes"
+                               AdditionalIncludeDirectories="includes;src/c;../core/includes;../fileio/includes;../output_stream/includes;../windows_tools/includes;../localization/includes;../../libs/MALLOC/includes;../../libs/intl;../../libs/dynamiclibrary/includes"
                                PreprocessorDefinitions="FORDLL;NDEBUG;_WINDOWS;_USRDLL;SOUND_EXPORTS;_CRT_SECURE_NO_DEPRECATE"
                                StringPooling="true"
                                RuntimeLibrary="2"
                        <Tool
                                Name="VCPreLinkEventTool"
                                Description="Make dependencies"
-                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\bin\dumpexts -o %%~nf.def -n fftw.dll %%f &gt;nul&#x0D;&#x0A;copy *.def fftwtmp.def &gt;nul&#x0D;&#x0A;copy ..\fftw_header.def+fftwtmp.def  ..\fftw.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
+                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Scilab_Windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)Scilab_Windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\bin\dumpexts -o %%~nf.def -n fftw.dll %%f &gt;nul&#x0D;&#x0A;copy *.def fftwtmp.def &gt;nul&#x0D;&#x0A;copy ..\fftw_header.def+fftwtmp.def  ..\fftw.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="LibScilab.lib"
+                               AdditionalDependencies="LibScilab.lib scilab_windows.lib"
                                OutputFile="../../bin/$(ProjectName).dll"
                                LinkIncremental="1"
                                ModuleDefinitionFile="fftw.def"
                                InlineFunctionExpansion="1"
                                FavorSizeOrSpeed="1"
                                WholeProgramOptimization="false"
-                               AdditionalIncludeDirectories="includes;src/c;../core/includes;../fileio/includes;../output_stream/includes;../localization/includes;../../libs/MALLOC/includes;../../libs/intl;../../libs/dynamiclibrary/includes"
+                               AdditionalIncludeDirectories="includes;src/c;../core/includes;../fileio/includes;../output_stream/includes;../windows_tools/includes;../localization/includes;../../libs/MALLOC/includes;../../libs/intl;../../libs/dynamiclibrary/includes"
                                PreprocessorDefinitions="FORDLL;NDEBUG;_WINDOWS;_USRDLL;SOUND_EXPORTS;_CRT_SECURE_NO_DEPRECATE"
                                StringPooling="true"
                                RuntimeLibrary="2"
                        <Tool
                                Name="VCPreLinkEventTool"
                                Description="Make dependencies"
-                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\bin\dumpexts -o %%~nf.def -n fftw.dll %%f &gt;nul&#x0D;&#x0A;copy *.def fftwtmp.def &gt;nul&#x0D;&#x0A;copy ..\fftw_header.def+fftwtmp.def  ..\fftw.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
+                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Scilab_Windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)Scilab_Windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\bin\dumpexts -o %%~nf.def -n fftw.dll %%f &gt;nul&#x0D;&#x0A;copy *.def fftwtmp.def &gt;nul&#x0D;&#x0A;copy ..\fftw_header.def+fftwtmp.def  ..\fftw.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="LibScilab.lib"
+                               AdditionalDependencies="LibScilab.lib scilab_windows.lib"
                                OutputFile="../../bin/$(ProjectName).dll"
                                LinkIncremental="1"
                                ModuleDefinitionFile="fftw.def"
                                        RelativePath=".\LibScilab_Import.def"
                                        >
                                </File>
+                               <File
+                                       RelativePath=".\scilab_windows_Import.def"
+                                       >
+                               </File>
                        </Filter>
                </Filter>
                <File
index d0225cc..9409365 100644 (file)
@@ -10,6 +10,7 @@
  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  *
  */
+#include <string.h>
 #include "sci_fftw_flags.h"
 #include "fftw_utilities.h"
 #include "MALLOC.h"
@@ -17,6 +18,9 @@
 #include "localization.h"
 #include "freeArrayOfString.h"
 #include "Scierror.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
 /*--------------------------------------------------------------------------*/
 extern unsigned cur_fftw_flags;
 /*--------------------------------------------------------------------------*/
@@ -177,13 +181,12 @@ int sci_fftw_flags(char *fname,unsigned long fname_len)
                        return(0);
                }
 
-               len = (int)strlen(Str[0]);
-               if ((Str3[0] = (char *)MALLOC(sizeof(char)*(len+1))) == NULL) 
+               Str3[0] = strdup(Str[0]);
+               if (Str3[0] == NULL) 
                {
                        Scierror(999,_("%s: No more memory.\n"),fname);
                        return(0);
                }
-               strcpy(Str3[0],Str[0]);
        }
        else 
        {
@@ -201,14 +204,14 @@ int sci_fftw_flags(char *fname,unsigned long fname_len)
                                        Scierror(999,_("%s: No more memory.\n"),fname);
                                        return(0);
                                }
-                               len = (int)strlen(Str[i]);
-                               if ((Str3[j-1] = (char *)MALLOC(sizeof(char)*(len+1))) == NULL) 
+
+                               Str3[j-1] = strdup(Str[i]);
+                               if (Str3[j-1] == NULL) 
                                {
                                        freeArrayOfString(Str3,j);
                                        Scierror(999,_("%s: No more memory.\n"),fname);
                                        return(0);
                                }
-                               strcpy(Str3[j-1],Str[i]);
                        }
                }
        }
diff --git a/scilab/modules/fftw/scilab_windows_Import.def b/scilab/modules/fftw/scilab_windows_Import.def
new file mode 100644 (file)
index 0000000..05c63be
--- /dev/null
@@ -0,0 +1,8 @@
+LIBRARY    scilab_windows.dll
+
+
+EXPORTS
+; --------------------------------------- 
+; scilab_windows
+; --------------------------------------- 
+ strdup_windows
index ad6ce95..12fd172 100644 (file)
@@ -13,6 +13,9 @@
 #include "stdlib.h"
 #include "fftwlibname.h"
 #include "MALLOC.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
 /*--------------------------------------------------------------------------*/ 
 char *fftwlibname = NULL;
 /*--------------------------------------------------------------------------*/ 
@@ -21,8 +24,7 @@ void setfftwlibname(char *libname)
        if (libname)
        {
                if (fftwlibname) {FREE(fftwlibname);fftwlibname = NULL;}
-               fftwlibname = (char *)MALLOC(sizeof(char)*(strlen(libname)+1));
-               strcpy(fftwlibname,libname);
+               fftwlibname = strdup(libname);
        }
 }
 /*--------------------------------------------------------------------------*/ 
@@ -32,8 +34,7 @@ char *getfftwlibname(void)
 
        if (fftwlibname)
        {
-               name = (char *)MALLOC(sizeof(char)*(strlen(fftwlibname)+1));
-               strcpy(name,fftwlibname);
+               name = strdup(fftwlibname);
        }
 
        return name;
index 5658f52..1140f3b 100644 (file)
  *
  */
 /*--------------------------------------------------------------------------*/
+#include <string.h>
 #include "gw_fileio.h"
 #include "stack-c.h"
 #include "MALLOC.h"
 #include "Scierror.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
 /*--------------------------------------------------------------------------*/
 int sci_filesep(char *fname,unsigned long fname_len)
 {
        static int n1,m1;
-       char *separator=NULL;
+       char *separator = NULL;
 
        CheckRhs(0,0);
        CheckLhs(1,1);
 
-       separator=(char*)MALLOC(sizeof(char)*(strlen(DIR_SEPARATOR)+1));
-       if (separator) strcpy(separator,DIR_SEPARATOR);
+       separator = strdup(DIR_SEPARATOR);
 
        n1 = 1;
        CreateVarFromPtr(Rhs+1,STRING_DATATYPE,(m1=(int)strlen(separator), &m1),&n1,&separator);
index d6e278c..9827abe 100644 (file)
@@ -12,6 +12,7 @@
 */
 /*--------------------------------------------------------------------------*/
 #include <stdlib.h>
+#include <string.h>
 #include "gw_fileio.h"
 #include "stack-c.h"
 #include "MALLOC.h"
@@ -19,6 +20,9 @@
 #include "localization.h"
 #include "PATH_MAX.h"
 #include "fullpath.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
 /*--------------------------------------------------------------------------*/
 int sci_fullpath(char *fname,unsigned long fname_len)
 {
@@ -39,9 +43,7 @@ int sci_fullpath(char *fname,unsigned long fname_len)
 
                if( get_full_path( fullpath, relPath, PATH_MAX*4 ) != NULL )
                {
-                       char *Output=NULL;
-                       Output=(char*)MALLOC((strlen(fullpath)+1)*sizeof(char));
-                       strcpy(Output,fullpath);
+                       char *Output = strdup(fullpath);
 
                        n1=1;
                        CreateVarFromPtr( Rhs+1,STRING_DATATYPE,(m1=(int)strlen(Output), &m1),&n1,&Output);
index a2fd328..a101e54 100644 (file)
@@ -17,6 +17,7 @@
  */
 /*--------------------------------------------------------------------------*/ 
 #include <stdio.h>
+#include <string.h>
 #include "gw_fileio.h"
 #include "isdir.h"
 #include "stack-c.h"
@@ -25,6 +26,9 @@
 #include "Scierror.h"
 #include "localization.h"
 #include "PATH_MAX.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
 /*--------------------------------------------------------------------------*/
 int sci_isdir(char *fname,unsigned long fname_len)
 {
@@ -70,13 +74,11 @@ int sci_isdir(char *fname,unsigned long fname_len)
                 */
                if(strcmp(path,"SCI") == 0)
                {
-                       myPath = (char*)MALLOC((m1+2)*sizeof(char)); /* +2 because the / added + \0 */
-                       strcpy(myPath,"SCI/");
+                       myPath = strdup("SCI/");
                }
                if(strcmp(path,"~") == 0)
                {
-                       myPath = (char*)MALLOC((m1+2)*sizeof(char)); /* +2 because the / added + \0 */
-                       strcpy(myPath,"~/");
+                       myPath = strdup("~/");
                }
                /* End of the crappy workaround */
 
index 34f7919..813087f 100644 (file)
@@ -24,6 +24,9 @@
 #include "localization.h"
 #include "freeArrayOfString.h"
 #include "charEncoding.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
 /*--------------------------------------------------------------------------*/
 static int GetIndexLastModifiedFileInList(char **ListFilename,int numberelemnts);
 /*--------------------------------------------------------------------------*/
@@ -101,8 +104,7 @@ int sci_newest(char *fname,unsigned long fname_len)
                                for (i = 1; i <= RhsBackup; i++)
                                {
                                        GetRhsVar(i,STRING_DATATYPE,&m1,&n1,&l1);
-                                       Str[i-1] = MALLOC(sizeof(char)*(strlen(cstk(l1))+1));
-                                       if (Str[i-1]) strcpy(Str[i-1],cstk(l1));
+                                       Str[i-1] = strdup(cstk(l1));
                                }
 
                                RetIndex = GetIndexLastModifiedFileInList(Str,RhsBackup);
index f8826ea..5933e44 100644 (file)
@@ -16,6 +16,9 @@
 #include <stdlib.h>
 #include "URIFileToFilename.h"
 #include "MALLOC.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
 /*--------------------------------------------------------------------------*/
 #if _MSC_VER
 #define strnicmp _strnicmp
@@ -34,13 +37,11 @@ char *URIFileToFilename(char *uri)
                if (isURIFile(uri))
                {
                        int pos = (int) strlen(URI_BEGIN);
-                       filename = (char*)MALLOC(sizeof(char)*(strlen(uri)+1));
-                       if (filename) strcpy(filename,&uri[pos]);
+                       filename = strdup(&uri[pos]);
                }
                else
                {
-                       filename = (char*)MALLOC(sizeof(char)*(strlen(uri)+1));
-                       if (filename) strcpy(filename,uri);
+                       filename = strdup(uri);
                }
        }
        return filename;
index 95a21aa..45d0354 100644 (file)
@@ -25,6 +25,9 @@
 #include "isdir.h"
 #include "MALLOC.h"
 #include "charEncoding.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
 /*--------------------------------------------------------------------------*/
 BOOL isdir(const char * path)
 {
@@ -37,14 +40,13 @@ BOOL isdir(const char * path)
        if (isDrive(path)) return TRUE;
        else
        {
-               char *pathTmp = NULL;
+               char *pathTmp = strdup(path);
                
-               pathTmp = MALLOC(sizeof(char)*((int)strlen(path)+1));
                if (pathTmp)
                {
                        wchar_t *pwTemp = NULL;
                        DWORD attr = 0;
-                       strcpy(pathTmp,path);
+
                        if ( (pathTmp[strlen(pathTmp)-1]=='\\') || (pathTmp[strlen(pathTmp)-1]=='/') )
                        {
                                pathTmp[strlen(pathTmp)-1]='\0';
index a96a23c..fc2cdbd 100644 (file)
@@ -1418,7 +1418,7 @@ int ChooseGoodFormat( char * c_format,char logflag, double *_grads,int n_grads )
 /*--------------------------------------------------------------------------*/
 char * copyFormatedValue( double value, const char format[5], int bufferSize )
 {
-  char * buffer = MALLOC( bufferSize * sizeof(char) ) ;
+  char * buffer = (char*)MALLOC( bufferSize * sizeof(char) ) ;
   char * res = NULL ;
   int resLength = 0 ;
 
@@ -1431,7 +1431,7 @@ char * copyFormatedValue( double value, const char format[5], int bufferSize )
 
   resLength =  (int)strlen( buffer ) + 1 ; /* + 1 <=> 0 terminating char */
 
-  res = MALLOC( resLength * sizeof(char) ) ;
+  res = (char*)MALLOC( resLength * sizeof(char) ) ;
 
   if ( res == NULL )
   {
index b539a9e..442662a 100644 (file)
@@ -20,6 +20,9 @@
 #include <stdio.h>
 #include "StringMatrix.h"
 #include "MALLOC.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
 
 /*----------------------------------------------------------------------------------*/
 StringMatrix * newFullStringMatrix( char ** textMat, int nbRow, int nbCol )
@@ -78,8 +81,7 @@ void copyStrMatElement( StringMatrix * mat, int row, int col, const char * copyS
   {
     FREE( changedString ) ;
   }
-  changedString = MALLOC( (strlen( copyStr ) + 1) * sizeof(char) ) ;
-  strcpy( changedString, copyStr ) ;
+  changedString = strdup(copyStr);
   mat->data[row + col * mat->nbRow] = changedString ;
 }
 /*----------------------------------------------------------------------------------*/
index 073b957..b0c816d 100644 (file)
 /* file: SetHashTable.c                                                   */
 /* desc : implementation of the scilab hashtable for the set procedure    */
 /*------------------------------------------------------------------------*/
-
+#include <string.h>
 #include "SetHashTable.h"
 #include "setHandleProperty.h"
 #include "Scierror.h"
 #include "localization.h"
 #include "getDictionarySetProperties.h"
 #include "MALLOC.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
 
 /** 
 * use for the singleton to know if the hashtable has already be created.
@@ -273,9 +276,7 @@ char **getDictionarySetProperties(int *sizearray)
                *sizearray = NB_PROPERTIES;
                for (i = 0;i < NB_PROPERTIES; i++)
                {
-                       char *propertyname = (char*)MALLOC(sizeof(char)*(strlen(propertyTable[i].key)+1));
-                       if (propertyname) strcpy(propertyname,propertyTable[i].key);
-                       dictionary [i] = propertyname;
+                       dictionary [i] = strdup(propertyTable[i].key);
                }
        }
        return dictionary;
index 38b7e10..80ee274 100644 (file)
 /* desc : define two hash table to be used in sci_set and sci_get         */
 /*        These hash table are based on the Scilab hashTable              */
 /*------------------------------------------------------------------------*/
-
+#include <string.h>
 #include "stricmp.h"
 
 #include "setGetHashTable.h"
 #include "MALLOC.h"
-
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
 /*--------------------------------------------------------------------------*/
 /* see http://www.cse.yorku.ca/~oz/hash.html */
 /* like in hashtable_localization by Allan Cornet */
@@ -70,13 +72,8 @@ int insertGetHashtable( GetPropertyHashTable * hashTable, char * key, getPropert
 {
   /* allocate a new key because the hashtable claims ownership */
   /* and will free it when destroyed */
-  char * copyKey   = NULL ;
-  int    keyLength =  (int)strlen( key ) + 1 ;
-
-  copyKey = MALLOC( keyLength * sizeof(char) ) ;
+  char * copyKey  =  strdup(key);
   if ( copyKey == NULL ) { return 0 ; }
-  strcpy( copyKey, key ) ;
-
   return hashtable_insert( hashTable, copyKey, value ) ;
 }
 /*--------------------------------------------------------------------------*/
@@ -100,12 +97,8 @@ int insertSetHashtable( SetPropertyHashTable * hashTable, char * key, setPropert
 {
   /* allocate a new key because the hashtable claims ownership */
   /* and will free it when destroyed */
-  char * copyKey   = NULL ;
-  int    keyLength =  (int)strlen( key ) + 1 ;
-
-  copyKey = MALLOC( keyLength * sizeof(char) ) ;
-  strcpy( copyKey, key ) ;
-
+  char * copyKey   = strdup(key);
+  if ( copyKey == NULL ) { return 0 ; }
   return hashtable_insert( hashTable, copyKey, value ) ;
 }
 /*--------------------------------------------------------------------------*/
index c2b19cb..01c8cca 100644 (file)
@@ -24,6 +24,9 @@
 #include "IsAScalar.h"
 #include "freeArrayOfString.h"
 #include "CallClipboard.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
 /*--------------------------------------------------------------------------*/
 int sci_ClipBoard(char *fname,unsigned long l)
 {
@@ -164,8 +167,7 @@ int sci_ClipBoard(char *fname,unsigned long l)
                           for (i=0; i<m1; i++) for (j=0; j<n1; j++) 
                             {
                               SizeofTextToSendInClipboard=SizeofTextToSendInClipboard+(int)strlen(Str[j*m1+i])+(int)strlen("\n");
-                              buffer[i*n1+j]=(char*)MALLOC(strlen(Str[j*m1+i])+1);
-                              strcpy(buffer[i*n1+j],Str[j*m1+i]);
+                                                         buffer[i*n1+j] = strdup(Str[j*m1+i]);
                             }
                           
                           TextToSendInClipboard=(char*)MALLOC( (SizeofTextToSendInClipboard)*sizeof(char) );
index 127db09..2cf1278 100644 (file)
@@ -23,8 +23,7 @@ char *buildMainWindowTitle(void)
        char *retTitle = NULL;
 
        #ifndef _MSC_VER
-       retTitle = (char*)MALLOC(sizeof(char)*(strlen(SCI_VERSION_STRING)+1));
-       if (retTitle) strcpy(retTitle,SCI_VERSION_STRING);
+       retTitle = strdup(SCI_VERSION_STRING);
        #else
        retTitle = buildMainWindowTitle_Windows();
        #endif
index f3c1f0a..42d8cf9 100644 (file)
@@ -16,6 +16,9 @@
 #include "getScilabJNIEnv.h"
 #include "getScilabObject.h"
 #include "MALLOC.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
 /*--------------------------------------------------------------------------*/ 
 char * getMainWindowTitle(void)
 {
@@ -50,8 +53,7 @@ char * getMainWindowTitle(void)
                                                                strValue = (*env)->GetStringUTFChars(env,jstr, 0);
                                                                if (strValue)
                                                                {
-                                                                       title = (char*)MALLOC(sizeof(char)*(strlen(strValue)+1));
-                                                                       if (title) strcpy(title,strValue);
+                                                                       title = strdup(strValue);
                                                                }
                                                                (*env)->ReleaseStringUTFChars(env, jstr , strValue);
                                                        }
index b83a249..e24d1f1 100644 (file)
 #include "TerminateHistoryManager.h"
 #include "getCommentDateSession.h"
 #include "Scierror.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
 /*--------------------------------------------------------------------------*/
 int C2F(sci_historymanager)(char *fname,unsigned long fname_len)
 {
        int l1 = 0,n1 = 0,m1 = 0;
-       char *Output=NULL;
+       char *Output = NULL;
 
        CheckRhs(0,1) ;
        CheckLhs(0,1) ;
 
        if (Rhs == 0)
        {
-               Output=(char*)MALLOC(4*sizeof(char));
-               if (historyIsEnabled()) strcpy(Output,"on");
-               else strcpy(Output,"off");
+               if (historyIsEnabled()) Output = strdup("on");
+               else Output = strdup("off");
        }
        else
        {
@@ -47,12 +49,10 @@ int C2F(sci_historymanager)(char *fname,unsigned long fname_len)
 
                        if ( (strcmp(param,"off")==0) || (strcmp(param,"on")==0) )
                        {
-                               Output=(char*)MALLOC(4*sizeof(char));
-
                                if (strcmp(param,"off")==0)
                                {
                                        if (historyIsEnabled()) TerminateHistoryManager();
-                                       strcpy(Output,"off");
+                                       Output = strdup("off");
                                }
                                else /* 'on' */
                                {
@@ -70,8 +70,7 @@ int C2F(sci_historymanager)(char *fname,unsigned long fname_len)
                                                        FREE(commentbeginsession);commentbeginsession=NULL;
                                                }
                                        }
-
-                                       strcpy(Output,"on");
+                                       Output = strdup("on");
                                }
                        }
                        else
index a68f72f..7c21ede 100644 (file)
@@ -28,6 +28,9 @@ extern "C"
        #include "InitializeHistoryManager.h"
        #include "TerminateHistoryManager.h"
        #include "freeArrayOfString.h"
+       #ifdef _MSC_VER
+       #include "strdup_windows.h"
+       #endif
 };
 /*------------------------------------------------------------------------*/
 #define MAXBUF 1024
@@ -94,8 +97,7 @@ BOOL appendLineToScilabHistory(char *line)
                int i = 0;
                char *cleanedline = NULL;
                /* remove space & carriage return at the end of line */
-               cleanedline = (char*) MALLOC(sizeof(char)*(strlen(line)+1));
-               strcpy(cleanedline,line);
+               cleanedline = strdup(line);
 
                /* remove carriage return at the end of line */
                for (i = (int) strlen(cleanedline); i > 0 ; i--)
@@ -379,8 +381,7 @@ char *HistoryManager::getFilename(void)
 
        if (! my_file.getFilename().empty())
        {
-               filename = (char*)MALLOC(sizeof(char)*(my_file.getFilename().length()+1));
-               if (filename) strcpy(filename,my_file.getFilename().c_str());
+               filename = strdup(my_file.getFilename().c_str());
        }
        return filename;
 }
@@ -481,13 +482,8 @@ char **HistoryManager::getAllLines(int *numberoflines)
                        string line = (*it_commands).get();
                        if (!line.empty())
                        {
-                               char *pLine = (char*)MALLOC(sizeof(char)*(strlen(line.c_str())+1));
-                               if (pLine)
-                               {
-                                       strcpy(pLine,line.c_str());
-                                       lines[i] = pLine;
-                                       i++;
-                               }
+                               lines[i] = strdup(line.c_str());
+                               i++;
                        }
                }
                *numberoflines = i;
@@ -506,11 +502,7 @@ char *HistoryManager::getLastLine(void)
                str = (*it_commands).get();
                if (!str.empty())
                {
-                       line = (char*)MALLOC(sizeof(char)*(strlen(str.c_str())+1));
-                       if (line)
-                       {
-                               strcpy(line,str.c_str());
-                       }
+                       line = strdup(str.c_str());
                }
        }
        return line;
@@ -539,12 +531,7 @@ char *HistoryManager::getNthLine(int N)
                                str = (*it_commands).get();
                                if (!str.empty())
                                {
-                                       line = (char*)MALLOC(sizeof(char)*(strlen(str.c_str())+1));
-                                       if (line)
-                                       {
-                                               strcpy(line,str.c_str());
-                                       }
-                                       return line;
+                                       return strdup(str.c_str());
                                }
                        }
                        i++;
@@ -614,8 +601,7 @@ char *HistoryManager::getPreviousLine(void)
                std::string line = my_search.getPreviousLine();
                if (!line.empty())
                {
-                       returnedline = (char*)MALLOC(sizeof(char)*(line.size()+1));
-                       if (returnedline) strcpy(returnedline,line.c_str());
+                       returnedline = strdup(line.c_str());
                }
        }
        return returnedline;
@@ -628,9 +614,7 @@ char *HistoryManager::getNextLine(void)
        if (my_search.getSize() > 0)
        {
                std::string line = my_search.getNextLine();
-               returnedline = (char*)MALLOC(sizeof(char)*(line.length()+1));
-               if (returnedline) strcpy(returnedline,line.c_str());
-
+               returnedline = strdup(line.c_str());
        }
        return returnedline;
 }
@@ -652,8 +636,7 @@ char * HistoryManager::getToken(void)
 
        if (!token.empty())
        {
-               returnedtoken = (char*)MALLOC(sizeof(char)*(token.length()+1));
-               if (returnedtoken) strcpy(returnedtoken,token.c_str());
+               returnedtoken = strdup(token.c_str());
        }
        return returnedtoken;
 }
index c0a39ae..628208e 100644 (file)
@@ -15,6 +15,9 @@ extern "C"
 {
 #include <string.h>
 #include <stdlib.h>
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
 }
 #include "HistorySearch.hxx"
 #include "MALLOC.h"
@@ -115,9 +118,7 @@ BOOL HistorySearch::search(void)
 
                                if (this->my_lines)
                                {
-                                       ptrLine = (char*)MALLOC(sizeof(char)*(strlen(line.c_str())+1));
-                                       if (ptrLine) strcpy(ptrLine,line.c_str());
-                                       this->my_lines[i-1] = ptrLine;
+                                       this->my_lines[i-1] = strdup(line.c_str());
                                }
 
                                if (this->my_linenumbers) this->my_linenumbers = (int*)REALLOC(this->my_linenumbers,i*(sizeof(int)));
@@ -153,9 +154,7 @@ BOOL HistorySearch::search(void)
 
                                if (this->my_lines)
                                {
-                                       ptrLine = (char*)MALLOC(sizeof(char)*(strlen(line.c_str())+1));
-                                       if (ptrLine) strcpy(ptrLine,line.c_str());
-                                       this->my_lines[i-1] = ptrLine;
+                                       this->my_lines[i-1] = strdup(line.c_str());
                                }
 
                                if (this->my_linenumbers) this->my_linenumbers = (int*)REALLOC(this->my_linenumbers,i*(sizeof(int)));
index d91aca2..17b5a53 100644 (file)
@@ -44,7 +44,7 @@
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               AdditionalIncludeDirectories="includes;../../libs/MALLOC/includes;../../libs/doublylinkedlist/includes;../core/includes;../output_stream/includes;../tclsci/includes;../tclsci/includes/tcltk/include;../../java/jdk/include/;../../java/jdk/include/win32;../../libs/intl;../call_scilab/includes"
+                               AdditionalIncludeDirectories="includes;../../libs/MALLOC/includes;../../libs/doublylinkedlist/includes;../core/includes;../output_stream/includes;../windows_tools/includes;../tclsci/includes;../tclsci/includes/tcltk/include;../../java/jdk/include/;../../java/jdk/include/win32;../../libs/intl;../call_scilab/includes"
                                PreprocessorDefinitions="_DEBUG;_USRDLL;JAVA_EXPORTS;_CRT_SECURE_NO_DEPRECATE"
                                MinimalRebuild="true"
                                BasicRuntimeChecks="0"
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               AdditionalIncludeDirectories="includes;../../libs/MALLOC/includes;../../libs/doublylinkedlist/includes;../core/includes;../output_stream/includes;../tclsci/includes;../tclsci/includes/tcltk/include;../../java/jdk/include/;../../java/jdk/include/win32;../../libs/intl;../call_scilab/includes"
+                               AdditionalIncludeDirectories="includes;../../libs/MALLOC/includes;../../libs/doublylinkedlist/includes;../core/includes;../output_stream/includes;../windows_tools/includes;../tclsci/includes;../tclsci/includes/tcltk/include;../../java/jdk/include/;../../java/jdk/include/win32;../../libs/intl;../call_scilab/includes"
                                PreprocessorDefinitions="_DEBUG;_USRDLL;JAVA_EXPORTS;_CRT_SECURE_NO_DEPRECATE"
                                MinimalRebuild="true"
                                BasicRuntimeChecks="0"
                        />
                        <Tool
                                Name="VCCLCompilerTool"
-                               AdditionalIncludeDirectories="includes;../../libs/MALLOC/includes;../../libs/doublylinkedlist/includes;../core/includes;../output_stream/includes;../tclsci/includes;../tclsci/includes/tcltk/include;../../java/jdk/include/;../../java/jdk/include/win32;../../libs/intl;../call_scilab/includes"
+                               AdditionalIncludeDirectories="includes;../../libs/MALLOC/includes;../../libs/doublylinkedlist/includes;../core/includes;../output_stream/includes;../windows_tools/includes;../tclsci/includes;../tclsci/includes/tcltk/include;../../java/jdk/include/;../../java/jdk/include/win32;../../libs/intl;../call_scilab/includes"
                                PreprocessorDefinitions="NDEBUG;_USRDLL;JAVA_EXPORTS;_CRT_SECURE_NO_DEPRECATE"
                                RuntimeLibrary="2"
                                EnableEnhancedInstructionSet="0"
                                ProgramDataBaseFileName="$(ConfigurationName)/vc80.pdb"
                                WarningLevel="3"
                                Detect64BitPortabilityProblems="false"
-                               DebugInformationFormat="3"
+                               DebugInformationFormat="0"
                        />
                        <Tool
                                Name="VCManagedResourceCompilerTool"
                        />
                        <Tool
                                Name="VCCLCompilerTool"
-                               AdditionalIncludeDirectories="includes;../../libs/MALLOC/includes;../../libs/doublylinkedlist/includes;../core/includes;../output_stream/includes;../tclsci/includes;../tclsci/includes/tcltk/include;../../java/jdk/include/;../../java/jdk/include/win32;../../libs/intl;../call_scilab/includes"
+                               AdditionalIncludeDirectories="includes;../../libs/MALLOC/includes;../../libs/doublylinkedlist/includes;../core/includes;../output_stream/includes;../windows_tools/includes;../tclsci/includes;../tclsci/includes/tcltk/include;../../java/jdk/include/;../../java/jdk/include/win32;../../libs/intl;../call_scilab/includes"
                                PreprocessorDefinitions="NDEBUG;_USRDLL;JAVA_EXPORTS;_CRT_SECURE_NO_DEPRECATE"
                                RuntimeLibrary="2"
                                EnableEnhancedInstructionSet="0"
                                ProgramDataBaseFileName="$(ConfigurationName)/vc80.pdb"
                                WarningLevel="3"
                                Detect64BitPortabilityProblems="false"
-                               DebugInformationFormat="3"
+                               DebugInformationFormat="0"
                        />
                        <Tool
                                Name="VCManagedResourceCompilerTool"
index 9a6baba..56500da 100644 (file)
@@ -10,6 +10,7 @@
  *
  */
 #include <stdlib.h>
+#include <string.h>
 #include "machine.h"
 #ifndef _MSC_VER
  #ifdef WITH_TK
@@ -24,6 +25,7 @@
 #include "getcommandlineargs.h"
 #ifdef _MSC_VER
 #include "../../../windows_tools/src/c/scilab_windows/SetScilabEnvironmentVariables.h"
+#include "strdup_windows.h"
 #endif
 #include "LaunchScilabSignal.h"
 
@@ -101,8 +103,7 @@ void Initialize(void)
     }
     else
        {
-               char *pathSCI=(char*)MALLOC((strlen(sciPath)+1)*sizeof(char));
-               strcpy(pathSCI,sciPath);
+               char *pathSCI = strdup(sciPath);
                SetScilabEnvironmentVariables(pathSCI);
                if (pathSCI) {FREE(pathSCI);pathSCI=NULL;}
        }
index 82a4d79..e818dc3 100644 (file)
@@ -16,6 +16,9 @@
 #include "system_getproperty.h"
 #include "getScilabJNIEnv.h"
 #include "MALLOC.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
 /*--------------------------------------------------------------------------*/ 
 char * system_getproperty(char *property,char *defaultproperty)
 {
@@ -44,8 +47,7 @@ char * system_getproperty(char *property,char *defaultproperty)
                                strValue = (*currentENV)->GetStringUTFChars(currentENV,jstrValue, 0);
                                if (strValue)
                                {
-                                       retValue = (char*)MALLOC(sizeof(char)*(strlen(strValue)+1));
-                                       if (retValue) strcpy(retValue,strValue);
+                                       retValue = strdup(strValue);
                                }
                                (*currentENV)->ReleaseStringUTFChars(currentENV, jstrValue , strValue);
                        }
index 14fc6d1..44ac362 100644 (file)
@@ -17,6 +17,9 @@
 #include "getScilabJNIEnv.h"
 #include "MALLOC.h"
 #include "catchIfJavaException.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
 /*--------------------------------------------------------------------------*/ 
 char * system_setproperty(char *property,char *value)
 {
@@ -53,8 +56,7 @@ char * system_setproperty(char *property,char *value)
                                                strPreviousValue = (*currentENV)->GetStringUTFChars(currentENV,jstrPreviousValue, 0);
                                                if (strPreviousValue)
                                                {
-                                                       retValue = (char*)MALLOC(sizeof(char)*(strlen(strPreviousValue)+1));
-                                                       if (retValue) strcpy(retValue,strPreviousValue);
+                                                       retValue = strdup(strPreviousValue);
                                                }
                                                (*currentENV)->ReleaseStringUTFChars(currentENV, jstrPreviousValue , strPreviousValue);
                                        }
index cb547e7..9be8066 100644 (file)
@@ -15,6 +15,9 @@
 #include <stdlib.h>
 #include "MALLOC.h"
 #include "hashtable_metanet.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
 /*--------------------------------------------------------------------------*/
 static struct hashtable *Table_Metanet=NULL;
 static unsigned hsize;
@@ -122,19 +125,15 @@ static ENTRY *SearchHashtable_string(struct hashtable *hash_table, const char* k
        {
                struct key_string *kElem=NULL;
 
-               k->Key_String=MALLOC((strlen(key)+1)*sizeof(char));
-               strcpy(k->Key_String,key);
+               k->Key_String = strdup(key);
 
                kElem=hashtable_search(hash_table,k);
 
                if (kElem)
                {
-                       return_entry=(ENTRY*)MALLOC(sizeof(ENTRY));
-                       return_entry->key=(char*)MALLOC(sizeof(char)*(strlen(key)+1));
-                       return_entry->data=(char*)MALLOC(sizeof(char)*(strlen(kElem->Key_String)+1));
-
-                       strcpy(return_entry->key,key);
-                       strcpy(return_entry->data,kElem->Key_String);
+                       return_entry = (ENTRY*)MALLOC(sizeof(ENTRY));
+                       return_entry->key = strdup(key);
+                       return_entry->data = strdup(kElem->Key_String);
                }
 
                FREE(k->Key_String);
@@ -169,11 +168,8 @@ ENTRY* myhsearch(ENTRY item,SCIACTION action)
                        k = (struct key_string*)MALLOC(sizeof(struct key_string));
                        v = (struct value_string*)MALLOC(sizeof(struct value_string));
 
-                       k->Key_String = (char *) MALLOC( sizeof(char) * (strlen(item.key)+1) );
-                       v->Value_String = (char *) MALLOC( sizeof(char) * (strlen(item.data)+1) );
-
-                       strcpy(k->Key_String,item.key);
-                       strcpy(v->Value_String,item.data);
+                       k->Key_String = strdup(item.key);
+                       v->Value_String = strdup(item.data);
 
                        InsertHashtable_string(Table_Metanet,k,v);
                        filled++;
index a0d5be8..d353616 100644 (file)
@@ -11,6 +11,7 @@
  *
  */
 #include <errno.h>
+#include <string.h>
 #include "PATH_MAX.h"
 #include "defs.h"
 #include "hashtable_metanet.h"
@@ -18,6 +19,9 @@
 #include "localization.h"
 #include "charEncoding.h"
 #include "Scierror.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
 
 static int CompString(char **s1,char **s2)
 {
@@ -83,12 +87,13 @@ void C2F(loadg)(char *path, int *lpath, char **name, int *lname, int *directed,
   pname = StripGraph(my_basename(path));
   *lname = (int)strlen(pname);
 
-  if ((*name = (char *)MALLOC((unsigned)sizeof(char)*(*lname + 1))) == NULL)
+  *name = strdup(pname);
+  if (*name == NULL)
   {
-    cerro(_("Running out of memory"));
-    return;
+         cerro(_("Running out of memory"));
+         return;
   }
-  strcpy(*name,pname);
+
   if (pname) { FREE(pname); pname=NULL;}
 #ifndef _MSC_VER
   if(!CheckGraphName(*name,dir))
index f4676b8..6c632cd 100644 (file)
@@ -44,7 +44,7 @@
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               AdditionalIncludeDirectories="../../includes;../../../../libs/MALLOC/includes;../../../output_stream/includes;../../../localization/includes;../../../core/includes;../../../../libs/hashtable;../../../../libs/intl"
+                               AdditionalIncludeDirectories="../../includes;../../../../libs/MALLOC/includes;../../../windows_tools/includes;../../../output_stream/includes;../../../localization/includes;../../../core/includes;../../../../libs/hashtable;../../../../libs/intl"
                                PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;METANET_EXPORTS"
                                MinimalRebuild="true"
                                BasicRuntimeChecks="0"
                        <Tool
                                Name="VCPreLinkEventTool"
                                Description="Make dependencies"
-                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)metanet_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)metanet_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n metanet.dll %%f &gt;nul&#x0D;&#x0A;copy *.def metanettmp.def &gt;nul&#x0D;&#x0A;copy ..\metanet_header.def+metanettmp.def  ..\metanet.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
+                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)metanet_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)metanet_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Scilab_Windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)Scilab_Windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n metanet.dll %%f &gt;nul&#x0D;&#x0A;copy *.def metanettmp.def &gt;nul&#x0D;&#x0A;copy ..\metanet_header.def+metanettmp.def  ..\metanet.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="LibScilab.lib metanet_f.lib"
+                               AdditionalDependencies="LibScilab.lib metanet_f.lib scilab_windows.lib"
                                OutputFile="../../../../bin/$(ProjectName).dll"
                                LinkIncremental="1"
                                ModuleDefinitionFile="metanet.def"
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               AdditionalIncludeDirectories="../../includes;../../../../libs/MALLOC/includes;../../../output_stream/includes;../../../localization/includes;../../../core/includes;../../../../libs/hashtable;../../../../libs/intl"
+                               AdditionalIncludeDirectories="../../includes;../../../../libs/MALLOC/includes;../../../windows_tools/includes;../../../output_stream/includes;../../../localization/includes;../../../core/includes;../../../../libs/hashtable;../../../../libs/intl"
                                PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;METANET_EXPORTS"
                                MinimalRebuild="true"
                                BasicRuntimeChecks="0"
                        <Tool
                                Name="VCPreLinkEventTool"
                                Description="Make dependencies"
-                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)metanet_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)metanet_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n metanet.dll %%f &gt;nul&#x0D;&#x0A;copy *.def metanettmp.def &gt;nul&#x0D;&#x0A;copy ..\metanet_header.def+metanettmp.def  ..\metanet.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
+                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)metanet_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)metanet_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Scilab_Windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)Scilab_Windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n metanet.dll %%f &gt;nul&#x0D;&#x0A;copy *.def metanettmp.def &gt;nul&#x0D;&#x0A;copy ..\metanet_header.def+metanettmp.def  ..\metanet.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="LibScilab.lib metanet_f.lib"
+                               AdditionalDependencies="LibScilab.lib metanet_f.lib scilab_windows.lib"
                                OutputFile="../../../../bin/$(ProjectName).dll"
                                LinkIncremental="1"
                                ModuleDefinitionFile="metanet.def"
                                InlineFunctionExpansion="1"
                                FavorSizeOrSpeed="1"
                                WholeProgramOptimization="false"
-                               AdditionalIncludeDirectories="../../includes;../../../../libs/MALLOC/includes;../../../output_stream/includes;../../../localization/includes;../../../core/includes;../../../../libs/hashtable;../../../../libs/intl"
+                               AdditionalIncludeDirectories="../../includes;../../../../libs/MALLOC/includes;../../../windows_tools/includes;../../../output_stream/includes;../../../localization/includes;../../../core/includes;../../../../libs/hashtable;../../../../libs/intl"
                                PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;METANET_EXPORTS"
                                StringPooling="true"
                                RuntimeLibrary="2"
                        <Tool
                                Name="VCPreLinkEventTool"
                                Description="Make dependencies"
-                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)metanet_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)metanet_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n metanet.dll %%f &gt;nul&#x0D;&#x0A;copy *.def metanettmp.def &gt;nul&#x0D;&#x0A;copy ..\metanet_header.def+metanettmp.def  ..\metanet.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
+                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)metanet_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)metanet_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Scilab_Windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)Scilab_Windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n metanet.dll %%f &gt;nul&#x0D;&#x0A;copy *.def metanettmp.def &gt;nul&#x0D;&#x0A;copy ..\metanet_header.def+metanettmp.def  ..\metanet.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="LibScilab.lib metanet_f.lib"
+                               AdditionalDependencies="LibScilab.lib metanet_f.lib scilab_windows.lib"
                                OutputFile="../../../../bin/$(ProjectName).dll"
                                LinkIncremental="1"
                                ModuleDefinitionFile="metanet.def"
                                InlineFunctionExpansion="1"
                                FavorSizeOrSpeed="1"
                                WholeProgramOptimization="false"
-                               AdditionalIncludeDirectories="../../includes;../../../../libs/MALLOC/includes;../../../output_stream/includes;../../../localization/includes;../../../core/includes;../../../../libs/hashtable;../../../../libs/intl"
+                               AdditionalIncludeDirectories="../../includes;../../../../libs/MALLOC/includes;../../../windows_tools/includes;../../../output_stream/includes;../../../localization/includes;../../../core/includes;../../../../libs/hashtable;../../../../libs/intl"
                                PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;METANET_EXPORTS"
                                StringPooling="true"
                                RuntimeLibrary="2"
                        <Tool
                                Name="VCPreLinkEventTool"
                                Description="Make dependencies"
-                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)metanet_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)metanet_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n metanet.dll %%f &gt;nul&#x0D;&#x0A;copy *.def metanettmp.def &gt;nul&#x0D;&#x0A;copy ..\metanet_header.def+metanettmp.def  ..\metanet.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
+                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)metanet_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)metanet_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Scilab_Windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)Scilab_Windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n metanet.dll %%f &gt;nul&#x0D;&#x0A;copy *.def metanettmp.def &gt;nul&#x0D;&#x0A;copy ..\metanet_header.def+metanettmp.def  ..\metanet.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="LibScilab.lib metanet_f.lib"
+                               AdditionalDependencies="LibScilab.lib metanet_f.lib scilab_windows.lib"
                                OutputFile="../../../../bin/$(ProjectName).dll"
                                LinkIncremental="1"
                                ModuleDefinitionFile="metanet.def"
diff --git a/scilab/modules/metanet/src/c/scilab_windows_Import.def b/scilab/modules/metanet/src/c/scilab_windows_Import.def
new file mode 100644 (file)
index 0000000..05c63be
--- /dev/null
@@ -0,0 +1,8 @@
+LIBRARY    scilab_windows.dll
+
+
+EXPORTS
+; --------------------------------------- 
+; scilab_windows
+; --------------------------------------- 
+ strdup_windows
index 8d8a399..c690a63 100644 (file)
  */
 /*--------------------------------------------------------------------------*/
 #include <stdio.h>
+#include <string.h>
 #include "gw_sound.h"
 #include "stack-c.h"
 #include "MALLOC.h"
 #include "Scierror.h"
 #include "localization.h"
+#if _MSC_VER
+#include "strdup_windows.h"
+#endif
 /*--------------------------------------------------------------------------*/
 static int BeepON=1;
 /*--------------------------------------------------------------------------*/
@@ -26,7 +30,7 @@ void BeepLinuxWindows(void);
 int sci_Beep(char *fname,unsigned long fname_len)
 {
        static int l1,n1,m1;
-       char *output=NULL ;
+       char *output = NULL ;
 
        Rhs=Max(0,Rhs);
        CheckRhs(0,1);
@@ -57,11 +61,11 @@ int sci_Beep(char *fname,unsigned long fname_len)
                if (BeepON) BeepLinuxWindows();
        }
 
-       output=(char*)MALLOC(6*sizeof(char));
+
        n1=1;
 
-       if (BeepON) strcpy(output,"on");
-       else strcpy(output,"off");
+       if (BeepON) output = strdup("on");
+       else output = strdup("off");
 
        CreateVarFromPtr( Rhs+1,STRING_DATATYPE,(m1=(int)strlen(output), &m1),&n1,&output);
        FREE(output);
diff --git a/scilab/modules/sound/scilab_windows_Import.def b/scilab/modules/sound/scilab_windows_Import.def
new file mode 100644 (file)
index 0000000..05c63be
--- /dev/null
@@ -0,0 +1,8 @@
+LIBRARY    scilab_windows.dll
+
+
+EXPORTS
+; --------------------------------------- 
+; scilab_windows
+; --------------------------------------- 
+ strdup_windows
index 0583852..8f1ef5b 100644 (file)
@@ -45,7 +45,7 @@
                                Name="VCCLCompilerTool"
                                AdditionalOptions="&#x0D;&#x0A;"
                                Optimization="0"
-                               AdditionalIncludeDirectories="includes;src/c;../core/includes;../fileio/includes;../output_stream/includes;../localization/includes;../../libs/MALLOC/includes;../../libs/intl"
+                               AdditionalIncludeDirectories="includes;src/c;../core/includes;../fileio/includes;../windows_tools/includes;../output_stream/includes;../localization/includes;../../libs/MALLOC/includes;../../libs/intl"
                                PreprocessorDefinitions="FORDLL;_DEBUG;_WINDOWS;_USRDLL;SOUND_EXPORTS;_CRT_SECURE_NO_DEPRECATE"
                                MinimalRebuild="true"
                                BasicRuntimeChecks="0"
                        <Tool
                                Name="VCPreLinkEventTool"
                                Description="Make dependencies"
-                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;&#x0D;&#x0A;"
+                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Scilab_Windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)Scilab_Windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;&#x0D;&#x0A;"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="LibScilab.lib"
+                               AdditionalDependencies="LibScilab.lib scilab_windows.lib"
                                OutputFile="../../bin/$(ProjectName).dll"
                                LinkIncremental="1"
                                ModuleDefinitionFile=""
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               AdditionalIncludeDirectories="includes;src/c;../core/includes;../fileio/includes;../output_stream/includes;../localization/includes;../../libs/MALLOC/includes;../../libs/intl"
+                               AdditionalIncludeDirectories="includes;src/c;../core/includes;../fileio/includes;../windows_tools/includes;../output_stream/includes;../localization/includes;../../libs/MALLOC/includes;../../libs/intl"
                                PreprocessorDefinitions="FORDLL;_DEBUG;_WINDOWS;_USRDLL;SOUND_EXPORTS;_CRT_SECURE_NO_DEPRECATE"
                                MinimalRebuild="true"
                                BasicRuntimeChecks="0"
                        <Tool
                                Name="VCPreLinkEventTool"
                                Description="Make dependencies"
-                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;"
+                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Scilab_Windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)Scilab_Windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="LibScilab.lib"
+                               AdditionalDependencies="LibScilab.lib scilab_windows.lib"
                                OutputFile="../../bin/$(ProjectName).dll"
                                LinkIncremental="1"
                                ModuleDefinitionFile=""
                                InlineFunctionExpansion="1"
                                FavorSizeOrSpeed="1"
                                WholeProgramOptimization="false"
-                               AdditionalIncludeDirectories="includes;src/c;../core/includes;../fileio/includes;../output_stream/includes;../localization/includes;../../libs/MALLOC/includes;../../libs/intl"
+                               AdditionalIncludeDirectories="includes;src/c;../core/includes;../fileio/includes;../windows_tools/includes;../output_stream/includes;../localization/includes;../../libs/MALLOC/includes;../../libs/intl"
                                PreprocessorDefinitions="FORDLL;NDEBUG;_WINDOWS;_USRDLL;SOUND_EXPORTS;_CRT_SECURE_NO_DEPRECATE"
                                StringPooling="true"
                                RuntimeLibrary="2"
                        <Tool
                                Name="VCPreLinkEventTool"
                                Description="Make dependencies"
-                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;&#x0D;&#x0A;"
+                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Scilab_Windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)Scilab_Windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;&#x0D;&#x0A;"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="LibScilab.lib"
+                               AdditionalDependencies="LibScilab.lib scilab_windows.lib"
                                OutputFile="../../bin/$(ProjectName).dll"
                                LinkIncremental="1"
                                ModuleDefinitionFile=""
                                InlineFunctionExpansion="1"
                                FavorSizeOrSpeed="1"
                                WholeProgramOptimization="false"
-                               AdditionalIncludeDirectories="includes;src/c;../core/includes;../fileio/includes;../output_stream/includes;../localization/includes;../../libs/MALLOC/includes;../../libs/intl"
+                               AdditionalIncludeDirectories="includes;src/c;../core/includes;../fileio/includes;../windows_tools/includes;../output_stream/includes;../localization/includes;../../libs/MALLOC/includes;../../libs/intl"
                                PreprocessorDefinitions="FORDLL;NDEBUG;_WINDOWS;_USRDLL;SOUND_EXPORTS;_CRT_SECURE_NO_DEPRECATE"
                                StringPooling="true"
                                RuntimeLibrary="2"
                        <Tool
                                Name="VCPreLinkEventTool"
                                Description="Make dependencies"
-                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;"
+                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Scilab_Windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)Scilab_Windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="LibScilab.lib"
+                               AdditionalDependencies="LibScilab.lib scilab_windows.lib"
                                OutputFile="../../bin/$(ProjectName).dll"
                                LinkIncremental="1"
                                ModuleDefinitionFile=""
                                        RelativePath=".\LibScilab_Import.def"
                                        >
                                </File>
+                               <File
+                                       RelativePath=".\scilab_windows_Import.def"
+                                       >
+                               </File>
                        </Filter>
                </Filter>
                <File
index 0d475e4..d895110 100644 (file)
@@ -129,7 +129,6 @@ static int GREP_NEW(GREPRESULTS *results,char **Inputs_param_one,int mn_one,char
                {
                        int Output_Start = 0;
                        int Output_End = 0;
-                       save = (char *)MALLOC( sizeof(char) * ( strlen(Inputs_param_two[x]) +1) );
                        save = strdup(Inputs_param_two[x]);
                        answer = pcre_private(Inputs_param_one[y],save,&Output_Start,&Output_End);
 
index 5691053..e86f2ce 100644 (file)
@@ -14,6 +14,7 @@
 #include "TextToPrint.h"
 #include "win_mem_alloc.h" /* MALLOC */
 #include "charEncoding.h"
+#include "strdup_windows.h"
 /*--------------------------------------------------------------------------*/
 static HDC PrinterHDC=NULL;
 static char PrinterName[2048];
@@ -316,13 +317,12 @@ void PrintFile(char *filename)
                                        }
                                        else
                                        {
-                                               LignePrint=(char*)MALLOC( (NombredeCaracteresparLignes+1)*sizeof(char));
-                                               strcpy(LignePrint,line);
+                                               LignePrint = strdup(line);
                                                TextOut (PrintDC,(tm.tmMaxCharWidth+10), Index2*HauteurCaractere, LignePrint, (int)strlen(LignePrint));
                                                if (LignePrint)
                                                {
                                                        FREE(LignePrint);
-                                                       LignePrint=NULL;
+                                                       LignePrint = NULL;
                                                }
                                                Index2 ++;
                                                if (Index2 == NbLigneParPage-4)