merge localization (from master)
Allan CORNET [Mon, 2 Feb 2009 13:40:58 +0000 (14:40 +0100)]
28 files changed:
scilab/modules/completion/src/c/getfilesdictionary.c
scilab/modules/console/src/cpp/ConsolePrintf.cpp
scilab/modules/core/sci_gateway/c/sci_getcwd.c
scilab/modules/core/src/c/cluni0.c
scilab/modules/core/src/c/getdynamicDebugInfo_Windows.c
scilab/modules/fileio/sci_gateway/c/sci_deletefile.c
scilab/modules/fileio/sci_gateway/c/sci_fileext.c
scilab/modules/fileio/sci_gateway/c/sci_findfiles.c
scilab/modules/fileio/sci_gateway/c/sci_fprintfMat.c
scilab/modules/fileio/sci_gateway/c/sci_fscanfMat.c
scilab/modules/fileio/sci_gateway/c/sci_fullpath.c
scilab/modules/fileio/sci_gateway/c/sci_getlongpathname.c
scilab/modules/fileio/sci_gateway/c/sci_getshortpathname.c
scilab/modules/fileio/src/c/do_xxprintf.c
scilab/modules/fileio/src/c/findfiles.c
scilab/modules/fileio/src/c/readline.c
scilab/modules/io/src/c/getenvc.c
scilab/modules/io/src/c/setenvc.c
scilab/modules/io/src/c/systemc.c
scilab/modules/localization/includes/charEncoding.h
scilab/modules/localization/includes/localization.h
scilab/modules/localization/includes/localizationJava.h
scilab/modules/localization/sci_gateway/c/sci_gettext.c
scilab/modules/output_stream/src/c/basout.c
scilab/modules/output_stream/src/c/sciprint.c
scilab/modules/shell/src/c/GetCommandLine.c
scilab/modules/shell/src/c/windows/TermConsole.c
scilab/modules/shell/src/c/windows/TermLine.c

index c0fabb9..74c3c42 100644 (file)
@@ -21,6 +21,7 @@
 #include "machine.h"
 #include "isdir.h"
 #include "charEncoding.h"
+#include "stack-def.h"
 /*--------------------------------------------------------------------------*/ 
 static void splitpath(char *composite,  char *path,  char *fname);
 static char **addPath(char **dictionary, int sizearray, char *path);
@@ -41,6 +42,7 @@ char **getfilesdictionary(char *somechars,int *sizearray,BOOL fullpath)
                char path[PATH_MAX];
                
                char filespec[PATH_MAX];
+               char szLocale[bsiz];
 
                char pathname[PATH_MAX];
                char filename[PATH_MAX];
@@ -82,7 +84,7 @@ char **getfilesdictionary(char *somechars,int *sizearray,BOOL fullpath)
                }
 
                C2F(cluni0)(path,pathextended,&out_n,(long)strlen(path),PATH_MAX);
-               dictionary = findfiles(pathextended, UTFToLocale(filespec), &sizeListReturned);
+               dictionary = findfiles(pathextended, UTFToLocale(filespec, szLocale), &sizeListReturned);
                if (fullpath)
                {
                        dictionary = addPath(dictionary, sizeListReturned, path);
index 431e694..ecae74c 100644 (file)
@@ -19,6 +19,7 @@
 extern "C" {
 #include "getScilabJavaVM.h"
 #include "charEncoding.h"
+#include "stack-def.h"
 }
 
 using namespace  org_scilab_modules_gui_bridge;
@@ -26,9 +27,13 @@ using namespace  org_scilab_modules_gui_bridge;
 int ConsolePrintf(char *line)
 {
        JavaVM *vm = getScilabJavaVM();
-       if (vm == NULL) { /* Java not yet or badly initialized */
-               printf("%s",UTFToLocale(line));
-       }else{
+       if (vm == NULL) 
+       { /* Java not yet or badly initialized */
+               char szLocale[bsiz];
+               printf("%s",UTFToLocale(line, szLocale));
+       }
+       else
+       {
                CallScilabBridge::display(vm, line);
        }
 
index 13271a8..c9b9e73 100644 (file)
@@ -36,7 +36,8 @@ int C2F(sci_getcwd)(char *fname,unsigned long fname_len)
        }
        else
        {
-               char *utfPath = localeToUTF(path);
+               char szTemp[bsiz];
+               char* utfPath = localeToUTF(path, szTemp);
 
                int n1 = 1;
                int m1 = (int)strlen(utfPath);
index 08cf94b..3491e1e 100644 (file)
@@ -20,6 +20,7 @@
 #include "cluni0.h"
 #include "GetenvB.h"
 #include "charEncoding.h"
+#include "stack-def.h"
 
 static char *SCI_a[]  = {  "SCI/"   , "sci/"   , "$SCI"   , "SCI\\"    , "sci\\"   , (char *) 0 };
 static char *HOME_a[] = {  "HOME/"  , "home/"  , "~/"     , "HOME\\"   , "home\\"  , "~\\" , "$HOME" , (char *) 0};
@@ -38,18 +39,19 @@ int C2F(cluni0)(char *in_name, char *out_name, int *out_n, long int lin, long in
        int nc= PATH_MAX;
        static char SCI[PATH_MAX],HOME[PATH_MAX],TMP[PATH_MAX];
        static int k;
-       char* in_nameL=NULL;
+       char *in_nameL = NULL;
+       char szTemp[bsiz];
     long int linL;
        char in_nameTmp[PATH_MAX];
        strncpy(in_nameTmp,in_name,lin);
-    in_nameTmp[lin]='\0';
+       in_nameTmp[lin]='\0';
        /* To convert to UTF-8 */
-    in_nameL = UTFToLocale(in_nameTmp);
+       in_nameL = UTFToLocale(in_nameTmp, szTemp);
        /* Get the new size of the converted string */
        linL=(long)strlen(in_nameL);
        /* Copy it back into the in_nameTmp variable */
        strncpy(in_nameTmp,in_nameL,linL);
-    in_nameL=in_nameTmp;
+       in_nameL=in_nameTmp;
        if ( ( n==0 ) || (getUpdateEnvVar() == 1) )
        {
                GetenvB("SCI"   , SCI ,nc);
index 9d339ad..8a270c4 100644 (file)
@@ -1,23 +1,25 @@
 /*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2008 - INRIA - Allan CORNET
- * 
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution.  The terms
- * are also available at    
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2008 - INRIA - Allan CORNET
+* 
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at    
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
 
 #include <windows.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include "stack-def.h"
 #include "MALLOC.h"
 #include "getDynamicDebugInfo_Windows.h"
 #include "localization.h"
 #include "../../../../libs/GetWindowsVersion/GetWindowsVersion.h"
+#include "charEncoding.h"
 /*--------------------------------------------------------------------------*/
 static char * GetRegKeyCPUIdentifier(void);
 static char * GetRegKeyVideoCard(void);
@@ -36,12 +38,14 @@ char **getDynamicDebugInfo_Windows(int *sizeArray)
        char *str_info = NULL;
        char **outputDynamicList=NULL;
        char *fromGetenv = NULL;
+       char szTemp[bsiz];
+
 
        MEMORYSTATUSEX statex;
        statex.dwLength = sizeof (statex);
        GlobalMemoryStatusEx (&statex);
 
-       
+
        str_info = (char*)MALLOC(sizeof(char)*BUFFER_LEN);
        if (str_info)
        {
@@ -130,52 +134,52 @@ char **getDynamicDebugInfo_Windows(int *sizeArray)
                {
                case OS_ERROR : default :
                        strcat(str_info ,"Windows Unknown");
-               break;
+                       break;
                case OS_WIN32_WINDOWS_NT_3_51 :
                        strcat(str_info ,"Windows NT 3.51");
-               break;
+                       break;
                case OS_WIN32_WINDOWS_NT_4_0 :
                        strcat(str_info ,"Windows NT 4.0");
-               break;
+                       break;
                case OS_WIN32_WINDOWS_95 :
                        strcat(str_info ,"Windows 95");
-               break;
+                       break;
                case OS_WIN32_WINDOWS_98 :
                        strcat(str_info ,"Windows 98");
-               break;
+                       break;
                case OS_WIN32_WINDOWS_Me :
                        strcat(str_info ,"Windows ME");
-               break;
+                       break;
                case OS_WIN32_WINDOWS_2000 :
                        strcat(str_info ,"Windows 2000");
-               break;
+                       break;
                case OS_WIN32_WINDOWS_XP :
                        strcat(str_info ,"Windows XP");
-               break;
+                       break;
                case OS_WIN32_WINDOWS_XP_64 :
                        strcat(str_info ,"Windows XP x64");
-               break;
+                       break;
                case OS_WIN32_WINDOWS_SERVER_2003 :
                        strcat(str_info ,"Windows Server 2003");
-               break;
+                       break;
                case OS_WIN32_WINDOWS_SERVER_2003_R2 :
                        strcat(str_info ,"Windows Server 2003 R2");
-               break;
+                       break;
                case OS_WIN32_WINDOWS_SERVER_2003_64 :
                        strcat(str_info ,"Windows Server 2003 x64");
-               break;
+                       break;
                case OS_WIN32_WINDOWS_VISTA :
                        strcat(str_info ,"Windows Vista");
-               break;
+                       break;
                case OS_WIN32_WINDOWS_VISTA_64 :
                        strcat(str_info ,"Windows Vista x64");
-               break;
+                       break;
                case OS_WIN32_WINDOWS_SERVER_2008 :
                        strcat(str_info ,"Windows Server 2008");
-               break;
+                       break;
                case OS_WIN32_WINDOWS_SERVER_2008_64 :
                        strcat(str_info ,"Windows Server 2008 x64");
-               break;
+                       break;
                }
                outputDynamicList = appendStringDebugInfo(outputDynamicList,&nb_info,str_info);
        }
@@ -208,27 +212,27 @@ char **getDynamicDebugInfo_Windows(int *sizeArray)
 
        outputDynamicList = appendStringDebugInfo(outputDynamicList,&nb_info,GetScreenResolution());
        outputDynamicList = appendStringDebugInfo(outputDynamicList,&nb_info,GetNumberMonitors());
-       
-       #define PATH_var "Path"
-       fromGetenv = getenv(PATH_var);
+
+#define PATH_var "Path"
+       fromGetenv = localeToUTF(getenv(PATH_var), szTemp);
        if (fromGetenv)
        {
                str_info = (char*)MALLOC( sizeof(char)*(strlen(fromGetenv) + strlen("%s : %s") + strlen(PATH_var) +1) );
                sprintf(str_info,"%s: %s", PATH_var, fromGetenv);
                outputDynamicList = appendStringDebugInfo(outputDynamicList,&nb_info,str_info);
        }
-               
-       #define COMSPEC_var "ComSpec"
-       fromGetenv = getenv(COMSPEC_var);
+
+#define COMSPEC_var "ComSpec"
+       fromGetenv = localeToUTF(getenv(COMSPEC_var), szTemp);
        if (fromGetenv)
        {
                str_info = (char*)MALLOC( sizeof(char)*(strlen(fromGetenv) + strlen("%s : %s") + strlen(COMSPEC_var) + 1) );
                sprintf(str_info,"%s: %s", COMSPEC_var,fromGetenv);
                outputDynamicList = appendStringDebugInfo(outputDynamicList,&nb_info,str_info);
        }
-       
-       #define TMP_var "TMP"
-       fromGetenv = getenv(TMP_var);
+
+#define TMP_var "TMP"
+       fromGetenv = localeToUTF(getenv(TMP_var), szTemp);
        if (fromGetenv)
        {
                str_info = (char*)MALLOC( sizeof(char)*(strlen(fromGetenv) + strlen("%s : %s") + strlen(TMP_var) + 1) );
@@ -236,8 +240,8 @@ char **getDynamicDebugInfo_Windows(int *sizeArray)
                outputDynamicList = appendStringDebugInfo(outputDynamicList,&nb_info,str_info);
        }
 
-       #define TEMP_var "TEMP"
-       fromGetenv = getenv(TEMP_var);
+#define TEMP_var "TEMP"
+       fromGetenv = localeToUTF(getenv(TEMP_var), szTemp);
        if (fromGetenv)
        {
                str_info = (char*)MALLOC( sizeof(char)*(strlen(fromGetenv) + strlen("%s : %s") + strlen(TEMP_var) + 1) );
@@ -245,8 +249,8 @@ char **getDynamicDebugInfo_Windows(int *sizeArray)
                outputDynamicList = appendStringDebugInfo(outputDynamicList,&nb_info,str_info);
        }
 
-       #define SCIHOME_var "SCIHOME"
-       fromGetenv = getenv(SCIHOME_var);
+#define SCIHOME_var "SCIHOME"
+       fromGetenv = localeToUTF(getenv(SCIHOME_var), szTemp);
        if (fromGetenv)
        {
                str_info = (char*)MALLOC( sizeof(char)*(strlen(fromGetenv) + strlen("%s : %s") + strlen(SCIHOME_var) + 1) );
@@ -294,7 +298,7 @@ static char * GetScreenResolution(void)
        int ResX = GetSystemMetrics(SM_CXSCREEN);
        int ResY = GetSystemMetrics(SM_CYSCREEN) ;
        char *Resolution = NULL;
-       
+
        ReleaseDC (NULL, hdc);
 
        Resolution = (char*)MALLOC( sizeof(char)*( strlen(_("Screen size: %d x %d %d bits")) + 32));
@@ -302,7 +306,7 @@ static char * GetScreenResolution(void)
        {
                sprintf(Resolution,_("Screen size: %d x %d %d bits"),ResX ,ResY,BitsByPixel);
        }
-       
+
        return Resolution;
 }
 /*--------------------------------------------------------------------------*/
@@ -326,7 +330,7 @@ static char ** appendStringDebugInfo(char **listInfo,int *sizeListInfo,char *str
 /*--------------------------------------------------------------------------*/
 static char * GetNumberMonitors(void)
 {
-       #define NBMONITORS "Number of Monitors: %d"
+#define NBMONITORS "Number of Monitors: %d"
        char *returnedStr = NULL;
        int nbMonitors = GetSystemMetrics(SM_CMONITORS) ;
 
@@ -341,8 +345,8 @@ static char * GetNumberMonitors(void)
 /*--------------------------------------------------------------------------*/
 static char * GetRegKeyVideoCard(void)
 {
-       #define KeyDisplayIdentifer "SYSTEM\\ControlSet001\\Control\\Class\\{4D36E968-E325-11CE-BFC1-08002BE10318}\\0000"
-       #define LenLine 255
+#define KeyDisplayIdentifer "SYSTEM\\ControlSet001\\Control\\Class\\{4D36E968-E325-11CE-BFC1-08002BE10318}\\0000"
+#define LenLine 255
 
        HKEY key;
        DWORD result;
index d9566b8..dd82e40 100644 (file)
@@ -28,10 +28,11 @@ int C2F(sci_deletefile)(char *fname,unsigned long fname_len)
        {
                int m1,n1,l1;
                char *VarName=NULL;
+               char szTemp[bsiz];
 
                GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);
                /* Bug 3089 */
-               VarName = UTFToLocale(cstk(l1));
+               VarName = UTFToLocale(cstk(l1), szTemp);
 
                n1=1;
                if ( deleteafile(VarName) )
index 064acd2..42388cb 100644 (file)
@@ -46,7 +46,8 @@ int C2F(sci_fileext)(char *fname,unsigned long fname_len)
                                if (Input_filenames[i])
                                {
                                        /* Bug 3089 */
-                                       Output_extensions[i] = FindFileExtension(UTFToLocale(Input_filenames[i]));
+                                       char szTempUTF[bsiz];
+                                       Output_extensions[i] = FindFileExtension(UTFToLocale(Input_filenames[i], szTempUTF));
                                }
                                else
                                {
index de72601..e7d54a8 100644 (file)
@@ -39,6 +39,7 @@ int C2F(sci_findfiles)(char *fname,unsigned long fname_len)
        char **FilesList = NULL;
        int sizeListReturned = 0;
        BOOL needtofreefilespec = FALSE;
+       char szTempLocale[bsiz];
 
        Rhs = Max(Rhs,0);
        CheckRhs(0,2) ;
@@ -104,7 +105,7 @@ int C2F(sci_findfiles)(char *fname,unsigned long fname_len)
        }
 
        C2F(cluni0)(path,pathextented,&out_n,(long)strlen(path),PATH_MAX); 
-       FilesList = findfiles(pathextented,UTFToLocale(filespec),&sizeListReturned);
+       FilesList = findfiles(pathextented,UTFToLocale(filespec, szTempLocale),&sizeListReturned);
        if (needtofreefilespec) { if (filespec) FREE(filespec); filespec = NULL;}
 
        if (FilesList)
index 4bf52b8..f75961e 100644 (file)
@@ -34,10 +34,11 @@ int int_objfprintfMat(char *fname,unsigned long fname_len)
        if (GetType(1) == sci_strings)
        {
                char *filename2 = NULL;
+               char szTemp[bsiz];
                GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);/* file name */
 
                /* BUG 3714 */
-               filename = UTFToLocale(cstk(l1));
+               filename = UTFToLocale(cstk(l1), szTemp);
        }
        else
        {
@@ -94,7 +95,8 @@ int int_objfprintfMat(char *fname,unsigned long fname_len)
 
        if ( Rhs >= 4 )
        {
-               for ( i=0 ; i < mS*nS ; i++) fprintf(f,"%s\n",UTFToLocale(Str2[i]));
+               char szTempLocale[bsiz];
+               for ( i=0 ; i < mS*nS ; i++) fprintf(f,"%s\n",UTFToLocale(Str2[i], szTempLocale));
        }
 
        for (i = 0 ; i < m2 ; i++ )
index f62bee0..91c65d8 100644 (file)
@@ -37,7 +37,8 @@ int int_objfscanfMat(char *fname,unsigned long fname_len)
        FILE  *f;
        char *Format = NULL;
        
-       char *shortcut_path = NULL; // filename process
+       char shortcut_path = NULL;      // filename process
+       char szTemp[bsiz];
        char *real_path     = NULL; //       "
        long int lout = 0;          //       "
        int out_n = 0;              //       "
@@ -74,7 +75,7 @@ int int_objfscanfMat(char *fname,unsigned long fname_len)
        GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);/* file name */
 
        /* BUG 3714 */
-       shortcut_path = UTFToLocale(cstk(l1));
+       shortcut_path = UTFToLocale(cstk(l1), szTemp);
 
        real_path     = (char*)MALLOC(sizeof(char*)*FILENAME_MAX);
        lout          = FILENAME_MAX;
index 0146297..077794d 100644 (file)
@@ -36,12 +36,13 @@ int C2F(sci_fullpath)(char *fname,unsigned long fname_len)
        if (GetType(1) == sci_strings)
        {
                static int l1,n1,m1;
-               char *relPath=NULL;
+               char relPath = NULL;
+               char szTemp[bsiz];
                char fullpath[PATH_MAX*4];
                
                GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);
                /* Bug 3089 */
-               relPath = UTFToLocale(cstk(l1));
+               relPath = UTFToLocale(cstk(l1), szTemp);
 
                if( _fullpath( fullpath, relPath, PATH_MAX*4 ) != NULL )
                {
index 3b7e078..c0a4252 100644 (file)
@@ -29,6 +29,7 @@ int C2F(sci_getlongpathname)(char *fname,unsigned long l)
 
        if (GetType(1) == sci_strings)
        {
+               char szTemp[bsiz];
                int bOK=FALSE;
                char *LongName=NULL;
                char *ShortName=NULL;
@@ -36,13 +37,13 @@ int C2F(sci_getlongpathname)(char *fname,unsigned long l)
                GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);
 
                /* bug 3089 */
-               ShortName = UTFToLocale(cstk(l1));
+               ShortName = UTFToLocale(cstk(l1), szTemp);
 
                LongName = getlongpathname(ShortName,&bOK);
 
                if (LongName) 
                {
-                   char *LongNameUTF=localeToUTF(LongName);
+                 char *LongNameUTF=localeToUTF(LongName, szTemp);
                        m1 = (int)strlen(LongNameUTF);
                        n1 = 1;
                        CreateVarFromPtr(Rhs+ 1,STRING_DATATYPE,&m1,&n1,&LongNameUTF);
index b94a6bf..1e3a66e 100644 (file)
@@ -30,18 +30,19 @@ int C2F(sci_getshortpathname)(char *fname,unsigned long l)
 
        if (GetType(1) == sci_strings)
        {
-               char *LongName=NULL;
+               char *LongName = NULL;
                char *ShortName=NULL;
+               char szTemp[bsiz];
 
                GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);
                /* Bug 3089 */
-               LongName = UTFToLocale(cstk(l1));
+               LongName = UTFToLocale(cstk(l1), szTemp);
 
                ShortName = getshortpathname(LongName,&bOK);
 
                if (ShortName) 
                {
-                   char *ShortNameUTF=localeToUTF(ShortName);
+                       char *ShortNameUTF = localeToUTF(ShortName, szTemp);
                        m1 =(int)strlen(ShortNameUTF);
                        n1 = 1;
                        CreateVarFromPtr( Rhs+1,STRING_DATATYPE,&m1,&n1,&ShortNameUTF);
index 92acefe..9097de3 100644 (file)
@@ -61,28 +61,40 @@ static int call_printf(XXPRINTF xxprintf,char *target,char *p,char *sval,int *as
        switch (choosetype (asterisk_count, conversion_type))
        {
                case choosetype (0, PF_S):
-                       if (isOutputInUTF()) {
+                       if (isOutputInUTF())
+                       {
                                retval += (*xxprintf) ((VPTR) target, p, sval);
-                } else {
-                        retval += (*xxprintf) ((VPTR) target, p, UTFToLocale(sval));
-                }
+                       } 
+                       else 
+                       {
+                               char szTempUTF[bsiz];
+                               retval += (*xxprintf) ((VPTR) target, p, UTFToLocale(sval, szTempUTF));
+                       }
                FREE(sval);
                break;
 
                case choosetype (1, PF_S):
-                       if (isOutputInUTF()) {
+                       if (isOutputInUTF())
+                       {
                                retval += (*xxprintf) ((VPTR) target, p, asterisk[0], sval);
-                       } else {
-                               retval += (*xxprintf) ((VPTR) target, p, asterisk[0], UTFToLocale(sval));
+                       }
+                       else
+                       {
+                               char szTempUTF[bsiz];
+                               retval += (*xxprintf) ((VPTR) target, p, asterisk[0], UTFToLocale(sval, szTempUTF));
                        }       
                FREE(sval);
                break;
 
                case choosetype (2, PF_S):
-                       if (isOutputInUTF()) {
+                       if (isOutputInUTF()) 
+                       {
                                retval += (*xxprintf) ((VPTR) target, p, asterisk[0], asterisk[1], sval);
-                       } else {
-                               retval += (*xxprintf) ((VPTR) target, p, asterisk[0], asterisk[1], UTFToLocale(sval));
+                       } 
+                       else 
+                       {
+                               char szTempUTF[bsiz];
+                               retval += (*xxprintf) ((VPTR) target, p, asterisk[0], asterisk[1], UTFToLocale(sval, szTempUTF));
                        }
                FREE(sval);
                break;
@@ -239,17 +251,18 @@ int do_xxprintf (char *fname, FILE *fp, char *format, int nargs, int argcount, i
                                        break;
                                default:
                                        /* putc */
-                                   UTFChar = readNextUTFChar(currentchar,&charBytes);
-                    currentchar += charBytes;
-                       if (isOutputInUTF() ) /** if output in UTF encoding*/
+                                       UTFChar = readNextUTFChar(currentchar,&charBytes);
+                                       currentchar += charBytes;
+                                       if (isOutputInUTF() ) /** if output in UTF encoding*/
                                        {
-                                         outStr = UTFChar;
-                      retval += charBytes;
+                                               outStr = UTFChar;
+                                               retval += charBytes;
                                        }
                                        else 
                                        {
-                        outStr  = UTFToLocale(UTFChar);
-                        retval += (int)strlen(outStr);
+                                               char szTemp[bsiz];
+                                               outStr  = UTFToLocale(UTFChar, szTemp);
+                                               retval += (int)strlen(outStr);
                                        }
                                        (*xxprintf) ((VPTR) target, "%s",outStr);       
                                        break;
index f2f4acb..f32acc6 100644 (file)
@@ -1,26 +1,27 @@
 /*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2007 - INRIA - Allan CORNET
- * ...
- * 
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution.  The terms
- * are also available at    
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-/*--------------------------------------------------------------------------*/ 
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2007 - INRIA - Allan CORNET
+* ...
+*
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+/*--------------------------------------------------------------------------*/
 #ifdef _MSC_VER
-       #include <Windows.h>
+#include <Windows.h>
 #else
-       #include <sys/types.h>
-       #include <dirent.h>
-       #include <errno.h>
-       #include "localization.h"
+#include <sys/types.h>
+#include <dirent.h>
+#include <errno.h>
+#include "localization.h"
 #endif
 #include <stdio.h>
 #include <string.h>
+#include "stack-def.h"
 #include "findfiles.h"
 #include "MALLOC.h"
 #include "BOOL.h"
 #ifdef _MSC_VER
 #include "strdup_windows.h"
 #endif
-/*--------------------------------------------------------------------------*/ 
+/*--------------------------------------------------------------------------*/
 #ifndef _MSC_VER
 static BOOL find_spec( char *filename ,char *filespec);
 #endif
-/*--------------------------------------------------------------------------*/ 
+/*--------------------------------------------------------------------------*/
 #ifdef _MSC_VER
 char **findfiles(char *path, char *filespec, int *sizeListReturned)
 {
@@ -41,7 +42,7 @@ char **findfiles(char *path, char *filespec, int *sizeListReturned)
        HANDLE hFile;
        WIN32_FIND_DATA FileInformation;
        int nbElements=0;
-       
+
 
        strPattern = (char*)MALLOC(sizeof(char)*(strlen(path)+strlen(filespec)+8));
        sprintf(strPattern,"%s/%s", path, filespec);
@@ -52,32 +53,33 @@ char **findfiles(char *path, char *filespec, int *sizeListReturned)
        {
                do
                {
-                       if ( strcmp(FileInformation.cFileName,".") && strcmp(FileInformation.cFileName,"..") )  
+                       if ( strcmp(FileInformation.cFileName,".") && strcmp(FileInformation.cFileName,"..") )
                        {
+                               char szTemp[bsiz];
                                char *utfFileName = NULL;
                                nbElements++;
                                if (ListFiles) ListFiles = (char**)REALLOC(ListFiles,sizeof(char*)*(nbElements));
                                else ListFiles = (char**)MALLOC(sizeof(char*)*(nbElements));
-                               utfFileName = localeToUTF(FileInformation.cFileName);
+                               utfFileName = localeToUTF(FileInformation.cFileName, szTemp);
                                ListFiles[nbElements-1] = strdup(utfFileName);
                        }
 
                } while(FindNextFile(hFile, &FileInformation) == TRUE);
        }
        FindClose(hFile);
-       
+
        *sizeListReturned = nbElements;
        return ListFiles;
 }
 #else
-/*--------------------------------------------------------------------------*/ 
+/*--------------------------------------------------------------------------*/
 char **findfiles(char *path, char *filespec, int *sizeListReturned)
 {
        char **ListFiles = NULL;
        int nbElements = 0;
        DIR *folder = NULL;
        struct dirent *read = NULL;
-       
+
        *sizeListReturned = 0;
 
        folder = opendir(path);
@@ -90,11 +92,18 @@ char **findfiles(char *path, char *filespec, int *sizeListReturned)
                                if ( find_spec(read->d_name ,filespec) )
                                {
                                        char *utfFileName = NULL;
+                                       char szTemp[bsiz];
                                        nbElements++;
-                                       if (ListFiles) ListFiles = (char**)REALLOC(ListFiles,sizeof(char*)*(nbElements));
-                                       else ListFiles = (char**)MALLOC(sizeof(char*)*(nbElements));
+                                       if (ListFiles)
+                                       {
+                                               ListFiles = (char**)REALLOC(ListFiles,sizeof(char*)*(nbElements));
+                                       }
+                                       else
+                                       {
+                                               ListFiles = (char**)MALLOC(sizeof(char*)*(nbElements));
+                                       }
 
-                                   utfFileName = localeToUTF(read->d_name);
+                                       utfFileName = localeToUTF(read->d_name, szTemp);
                                        ListFiles[nbElements-1] = strdup(utfFileName);
                                }
                        }
@@ -110,8 +119,16 @@ char **findfiles(char *path, char *filespec, int *sizeListReturned)
        return ListFiles;
 }
 #endif
-/*--------------------------------------------------------------------------*/ 
+/*--------------------------------------------------------------------------*/
 #ifndef _MSC_VER
+/**
+* Check if the file matches the mask
+* '*' for all chars
+* '?' for only one
+* @TODO check if it can be optimized
+* @param filename the filename
+* @param filespec the mask
+*/
 static BOOL find_spec( char *filename ,char *filespec)
 {
        char *any = NULL;
@@ -149,4 +166,4 @@ static BOOL find_spec( char *filename ,char *filespec)
        return TRUE;
 }
 #endif
-/*--------------------------------------------------------------------------*/ 
+/*--------------------------------------------------------------------------*/
index b93f13c..4dfecae 100644 (file)
@@ -20,6 +20,7 @@
 #include "readline.h"
 #include "filesmanagement.h"
 #include "charEncoding.h"
+#include "stack-def.h"
 /*--------------------------------------------------------------------------*/
 #if (defined(sun) && !defined(SYSV)) || defined(sgi)
 #define SEEK_SET 0
@@ -38,7 +39,8 @@ int LineRead(FILE *fd,char buf[],int n,int *cnt,int *nr)
 {
   int c,count,info;
   long int offset;
-  char *tmpChar;
+  char *tmpChar = NULL;
+       char szTemp[bsiz];
   count=0;
   *nr=0;
   
@@ -105,7 +107,7 @@ int LineRead(FILE *fd,char buf[],int n,int *cnt,int *nr)
   }
   *cnt=count;
   /** Convert from system locale encoding to UTF encoding */
-  tmpChar = localeToUTF(buf);
+  tmpChar = localeToUTF(buf, szTemp);
   *cnt = (int)strlen(tmpChar)+1;
   strcpy(buf,tmpChar);
   return(info);
index 8193edb..ddca559 100644 (file)
@@ -1,67 +1,72 @@
 /*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2006 - INRIA
- * Copyright (C) 2008 - INRIA - Allan CORNET
- * 
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution.  The terms
- * are also available at    
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2006 - INRIA
+* Copyright (C) 2008 - INRIA - Allan CORNET
+*
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
 
-#include <stdlib.h> 
+#include <stdlib.h>
 #include <string.h> /* strlen */
 #ifdef _MSC_VER
-       #include <Windows.h> /* GetEnvironmentVariable */
-       #include "strdup_windows.h"
+#include <Windows.h> /* GetEnvironmentVariable */
+#include "strdup_windows.h"
 #endif
+#include "stack-def.h"
 #include "MALLOC.h"
 #include "getenvc.h"
 #include "localization.h"
 #include "sciprint.h"
 #include "PATH_MAX.h"
 #include "FileExist.h"
+#include "charEncoding.h"
 /*--------------------------------------------------------------------------*/
 #ifndef _MSC_VER
 static void searchenv_others(const char *filename, const char *varname,
-                           char *pathname);
+                                                        char *pathname);
 #endif
 /*--------------------------------------------------------------------------*/
 void C2F(getenvc)(int *ierr,char *var,char *buf,int *buflen,int *iflag)
 {
-       #ifdef _MSC_VER
-       if (GetEnvironmentVariable(var,buf,(DWORD)*buflen) == 0)
+       char szTemp[bsiz];
+       char *locale = NULL;
+#ifdef _MSC_VER
+       if (GetEnvironmentVariable(UTFToLocale(var, szTemp),buf,(DWORD)*buflen) == 0)
        {
                if ( *iflag == 1 ) sciprint(_("Undefined environment variable %s.\n"),var);
                *ierr=1;
        }
        else
        {
-               *buflen = (int)strlen(buf);
+               locale = localeToUTF(buf, szTemp);
+               *buflen = (int)strlen(locale);
+               strncpy(buf,locale,*buflen);
                *ierr=0;
        }
-       #else
-       char *local;
-       if ( (local=getenv(var)) == 0)
+#else
+       if ( (locale=localeToUTF(getenv(UTFToLocale(var, szTemp)), szTemp) ) == 0)
        {
                if ( *iflag == 1 ) sciprint(_("Undefined environment variable %s.\n"),var);
                *ierr=1;
        }
        else
        {
-               strncpy(buf,local,*buflen);
-               *buflen = strlen(buf);
+               *buflen = (int)strlen(locale);
+               strcpy(buf,locale);
                *ierr=0;
        }
-       #endif
+#endif
 }
 /*--------------------------------------------------------------------------*/
 #ifndef _MSC_VER
-static void searchenv_others(const char *filename, 
-                           const char *varname,
-                           char *pathname)
+static void searchenv_others(const char *filename,
+                                                        const char *varname,
+                                                        char *pathname)
 {
        char *cp = NULL;
 
@@ -72,7 +77,7 @@ static void searchenv_others(const char *filename,
                strcpy(pathname, filename);
                return;
        }
-       
+
        cp = getenv(varname);
        if(cp == NULL)
        {
@@ -84,7 +89,7 @@ static void searchenv_others(const char *filename,
        {
                char *concat = NULL;
                *pathname = '\0';
-        concat = pathname;
+               concat = pathname;
                /* skip PATH_SEPARATOR[0] and empty entries */
                while( (*cp) && (*cp == PATH_SEPARATOR[0]) )
                {
@@ -98,14 +103,14 @@ static void searchenv_others(const char *filename,
                        cp++;
                        concat++;
                }
-               
+
                if ( concat == pathname )
                {
                        /* filename not found */
                        *pathname = '\0';
                        return;
                }
-               
+
                if( *(concat-1) != DIR_SEPARATOR[0] )
                {
                        /* add directory separator */
@@ -133,16 +138,20 @@ char *searchEnv(const char *name,const char *env_var)
 {
        char *buffer = NULL;
        char fullpath[PATH_MAX];
+       char szLocale[bsiz];
 
        strcpy(fullpath,"");
 
-       #if _MSC_VER 
-               _searchenv(name,env_var,fullpath);
-       #else
-               searchenv_others(name,env_var,fullpath);
-       #endif
+#if _MSC_VER
+       _searchenv((const char*)UTFToLocale((char*)name, szLocale),(const char*)env_var,fullpath);
+#else
+       searchenv_others(UTFToLocale(name, szLocale),env_var,fullpath);
+#endif
 
-       if (strlen(fullpath) > 0) buffer = strdup(fullpath);
+       if (strlen(fullpath) > 0)
+       {
+               buffer = strdup(localeToUTF(fullpath, szLocale));
+       }
        return buffer;
 }
 /*--------------------------------------------------------------------------*/
index 4eec4b4..17f5a99 100644 (file)
@@ -1,14 +1,14 @@
 /*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2005 - INRIA - Allan CORNET
- * 
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution.  The terms
- * are also available at    
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2005 - INRIA - Allan CORNET
+* 
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at    
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
 
 #ifdef _MSC_VER
 #include <windows.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include "stack-def.h"
 #include "setenvc.h"
 #include "../../tclsci/includes/setenvtcl.h"
 #include "MALLOC.h" /* MALLOC */
-
+#include "charEncoding.h"
 #ifdef _MSC_VER
 #define putenv _putenv
 static char *env = NULL;
@@ -27,20 +28,26 @@ static char *env = NULL;
 
 static int UpdateEnvVar = 0;
 /*--------------------------------------------------------------------------*/
-BOOL setenvc(char *string,char *value)
+BOOL setenvc(char *stringIn,char *valueIn)
 {
        int ret = 0;
        /* 2 is = and \0 */
+       char *string = NULL;
+       char *value = NULL;
+       char szTemp[bsiz];
+       char *env;
 
-       char *env = (char*)MALLOC((strlen(string)+strlen(value)+2)*sizeof(char));
+       string = UTFToLocale(stringIn, szTemp);
+       value = UTFToLocale(valueIn, szTemp);
+       env = (char*)MALLOC((strlen(string)+strlen(value)+2)*sizeof(char));
 
 #ifdef _MSC_VER
        /* 
-        On Windows :
-     each process has two copies of the environment variables,
-     one managed by the OS and one managed by the C library. We set
-     the value in both locations, so that other software that looks in
-     one place or the other is guaranteed to see the value.
+       On Windows :
+       each process has two copies of the environment variables,
+       one managed by the OS and one managed by the C library. We set
+       the value in both locations, so that other software that looks in
+       one place or the other is guaranteed to see the value.
        */
        SetEnvironmentVariableA(string,value);
 #endif
@@ -58,16 +65,16 @@ BOOL setenvc(char *string,char *value)
        {
                UpdateEnvVar = 1;
                ret = TRUE;
-    }
+       }
 
        if (ret) {
-               setenvtcl(string,value);
+               setenvtcl(stringIn,valueIn);
        }
 
 
        FREE(env);
 
-  return ret;
+       return ret;
 }
 /*--------------------------------------------------------------------------*/
 int getUpdateEnvVar(void)
index d884e7f..29ee1d7 100644 (file)
@@ -20,6 +20,7 @@
 #include "systemc.h"
 #include "tmpdir.h"
 #include "charEncoding.h"
+#include "stack-def.h"
 /*--------------------------------------------------------------------------*/
 #ifdef _MSC_VER
 #include "FileExist.h"
@@ -31,7 +32,8 @@ int C2F(systemc)(char *command, int *stat)
 #ifdef _MSC_VER
        {
                BOOL Status=FALSE;
-               Status=CallWindowsShell(UTFToLocale(command),FALSE);
+               char szLocale[bsiz];
+               Status=CallWindowsShell(UTFToLocale(command, szLocale),FALSE);
                if (Status)
                {
                        *stat=(int) 0;
@@ -44,7 +46,8 @@ int C2F(systemc)(char *command, int *stat)
 #else
        {
                int status;
-               status=system(UTFToLocale(command));
+               char szLocale[bsiz];
+               status=system(UTFToLocale(command, szLocale));
                *stat=(int) status;
        }
 #endif
index 0fdaf06..d0788f8 100644 (file)
@@ -56,3 +56,4 @@ char* readNextUTFChar(char* utfstream,int* size);
 
 
 #endif /* __CHARENCODING_H__ */
+
index 9fbcca1..80cd360 100644 (file)
@@ -1,17 +1,17 @@
 /*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2007 - INRIA - Sylvestre LEDRU
- * 
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution.  The terms
- * are also available at    
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2007 - INRIA - Sylvestre LEDRU
+* 
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at    
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
 /**
- * Declaration of the basic localization methods
- */
+* Declaration of the basic localization methods
+*/
 #ifndef __LOCALIZATION_H__
 #define __LOCALIZATION_H__
 /*--------------------------------------------------------------------------*/ 
@@ -23,6 +23,7 @@
 /* Have been able to find the libintl.h file on the system */
 #include <libintl.h>
 #include "stack-def.h"
+#include "charEncoding.h"
 
 #define _(String)  gettext(String)/** for console message*/
 #define _t(String1,String2,n) ngettext (String1,String2,n)
index ceded82..60cd745 100644 (file)
@@ -1,17 +1,17 @@
 /*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2009 - DIGITEO - Sylvestre LEDRU
- * 
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution.  The terms
- * are also available at    
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2009 - DIGITEO - Sylvestre LEDRU
+* 
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at    
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
 /**
- * Declaration of the basic localization methods
- */
+* Declaration of the basic localization methods
+*/
 #ifndef __LOCALIZATIONJAVA_H__
 #define __LOCALIZATIONJAVA_H__
 /*--------------------------------------------------------------------------*/ 
 #include <libintl.h>
 #include "stack-def.h"
 /* This piece of code has been written because of the bug #4005
- * in version 5.0, we were using two localization system (native and 
- * Java).
- * Now, only the native one is used. 
- * However, for an unknown reason, gettext() is not working. Only 
- * dgettext is */
+* in version 5.0, we were using two localization system (native and 
+* Java).
+* Now, only the native one is used. 
+* However, for an unknown reason, gettext() is not working. Only 
+* dgettext is */
 #define scigettext(String1) dgettext(NAMELOCALIZATIONDOMAIN,String1)
 
 #else
index 1a1c8ed..ffb4a16 100644 (file)
@@ -1,14 +1,14 @@
 /*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2008 - INRIA - Sylvestre LEDRU
- * 
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution.  The terms
- * are also available at    
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2008 - INRIA - Sylvestre LEDRU
+* 
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at    
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
 #include <string.h>
 #include "MALLOC.h"
 #include "stack-c.h"
@@ -24,61 +24,62 @@ int C2F(sci_gettext)(char *fname,unsigned long fname_len)
        CheckLhs(1,1);
 
        if ( (GetType(1) == sci_strings) )
-               {
-                       static int l1,n1,m1;
+       {
+               static int l1,n1,m1;
+
+               char *msgid=NULL;
+               char *TranslatedString=NULL;
 
-                       char *msgid=NULL;
-                       char *TranslatedString=NULL;
-                        
-                        int revertStrsub = FALSE;
-                        
-                       GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);
-                       msgid=cstk(l1);
+               int revertStrsub = FALSE;
 
-                       /* This stupid stuff is necessary because scilab is add slashes
-                        * and we need to remove them
-                        * An other solution might be to replace the string "\x" by it
-                        * real code 
-                       */
-                       if (strchr(msgid, '\\')!=NULL){
-                               /* There is an \ in the string process to replace */
-                               
-                               /* We always have something from this functions because gettext
-                                * is returning the same string if it cannot find it */
+               GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);
+               msgid=cstk(l1);
 
-                               msgid=strsub(msgid, "\\n", "\n"); /* linefeed */
-                               msgid=strsub(msgid, "\\t", "\t"); /* horizontal tab */
-                               msgid=strsub(msgid, "\\r", "\r"); /* carriage return */
-                               msgid=strsub(msgid, "\\v", "\v"); /* vertical tab */
-                               msgid=strsub(msgid, "\\f", "\f"); /* form feed */
-                               msgid=strsub(msgid, "\\\\", "\\"); /* backslash */
-                               msgid=strsub(msgid, "\\\"", "\""); /* double quote */
+               /* This stupid stuff is necessary because scilab is add slashes
+               * and we need to remove them
+               * An other solution might be to replace the string "\x" by it
+               * real code 
+               */
+               if (strchr(msgid, '\\')!=NULL){
+                       /* There is an \ in the string process to replace */
 
-                                revertStrsub = TRUE;
-                       }
-                       TranslatedString=gettext(msgid);
-             /* Add removed slashes */
-                       if (revertStrsub)
-                       {
-                TranslatedString=strsub(TranslatedString, "\\", "\\\\"); /* backslash */
-                TranslatedString=strsub(TranslatedString, "\"", "\\\""); /* double quote */
-                TranslatedString=strsub(TranslatedString, "\n", "\\n"); /* linefeed */
-                TranslatedString=strsub(TranslatedString, "\t", "\\t"); /* horizontal tab */
-                TranslatedString=strsub(TranslatedString, "\r", "\\r"); /* carriage return */
-                TranslatedString=strsub(TranslatedString, "\v", "\\v"); /* vertical tab */
-                TranslatedString=strsub(TranslatedString, "\f", "\\f"); /* form feed */
-             }
+                       /* We always have something from this functions because gettext
+                       * is returning the same string if it cannot find it */
 
-                       n1=1;
-                       CreateVarFromPtr(Rhs+1,STRING_DATATYPE,(m1=(int)strlen(TranslatedString), &m1),&n1,&TranslatedString);
-                       LhsVar(1)=Rhs+1;
-                       C2F(putlhsvar)();
-                       return 0;
+                       msgid=strsub(msgid, "\\n", "\n"); /* linefeed */
+                       msgid=strsub(msgid, "\\t", "\t"); /* horizontal tab */
+                       msgid=strsub(msgid, "\\r", "\r"); /* carriage return */
+                       msgid=strsub(msgid, "\\v", "\v"); /* vertical tab */
+                       msgid=strsub(msgid, "\\f", "\f"); /* form feed */
+                       msgid=strsub(msgid, "\\\\", "\\"); /* backslash */
+                       msgid=strsub(msgid, "\\\"", "\""); /* double quote */
+
+                       revertStrsub = TRUE;
                }
-       else
+               TranslatedString=gettext(msgid);
+
+               /* Add removed slashes */
+               if (revertStrsub)
                {
-                       Scierror(999,_("%s: Wrong type for input argument #%d: String expected.\n"),fname,1);
-                       return 0;
+                       TranslatedString=strsub(TranslatedString, "\\", "\\\\"); /* backslash */
+                       TranslatedString=strsub(TranslatedString, "\"", "\\\""); /* double quote */
+                       TranslatedString=strsub(TranslatedString, "\n", "\\n"); /* linefeed */
+                       TranslatedString=strsub(TranslatedString, "\t", "\\t"); /* horizontal tab */
+                       TranslatedString=strsub(TranslatedString, "\r", "\\r"); /* carriage return */
+                       TranslatedString=strsub(TranslatedString, "\v", "\\v"); /* vertical tab */
+                       TranslatedString=strsub(TranslatedString, "\f", "\\f"); /* form feed */
                }
+
+               n1=1;
+               CreateVarFromPtr(Rhs+1,STRING_DATATYPE,(m1=(int)strlen(TranslatedString), &m1),&n1,&TranslatedString);
+               LhsVar(1)=Rhs+1;
+               C2F(putlhsvar)();
+               return 0;
+       }
+       else
+       {
+               Scierror(999,_("%s: Wrong type for input argument #%d: String expected.\n"),fname,1);
+               return 0;
+       }
 }
 /*--------------------------------------------------------------------------*/
index 95e29a0..4fb3486 100644 (file)
@@ -29,6 +29,7 @@ extern int C2F(writelunitstring)();
 int C2F(basout)(int *io, int *lunit, char *string,long int nbcharacters)
 {
        char *buffer = NULL;
+       char szlocaleToUTF[bsiz];
        static int ich;
 
        int i = 0;
@@ -81,7 +82,7 @@ int C2F(basout)(int *io, int *lunit, char *string,long int nbcharacters)
        } 
        else
        {
-               buffer = UTFToLocale(string); /** convert string to system locale encoding for file output*/
+               buffer = UTFToLocale(string, szlocaleToUTF); /** convert string to system locale encoding for file output*/
         nbcharacters = (long int)strlen(buffer);
                /* Output to a file */
                if (*lunit == C2F(iop).wio) 
index 72d9f84..a9d3a28 100644 (file)
@@ -88,6 +88,7 @@ void printf_scilab(char *buffer,BOOL withDiary)
 {
        if (buffer)
        {
+               char szLocale[bsiz];
                if (getScilabMode() == SCILAB_STD)
                {
                        ConsolePrintf(buffer);
@@ -95,16 +96,16 @@ void printf_scilab(char *buffer,BOOL withDiary)
                else
                {
                        #ifdef _MSC_VER
-                       TermPrintf_Windows(UTFToLocale(buffer));
+                       TermPrintf_Windows(UTFToLocale(buffer, szLocale));
                        #else
-                       printf("%s",UTFToLocale(buffer));
+                       printf("%s",UTFToLocale(buffer, szLocale));
                        #endif
                }
 
                if ( (withDiary) && getdiary() ) 
                {
-                       int lstr = (int)strlen(UTFToLocale(buffer));
-                       diary_nnl(UTFToLocale(buffer),&lstr);
+                       int lstr = (int)strlen(UTFToLocale(buffer, szLocale));
+                       diary_nnl(UTFToLocale(buffer, szLocale),&lstr);
                }
        }
 }
index fe55e68..246acc0 100644 (file)
@@ -23,6 +23,7 @@
 #if _MSC_VER
 #include "TermReadAndProcess.h"
 #endif
+#include "stack-def.h"
 
 #ifdef _MSC_VER
 #define IMPORT_SIGNAL __declspec(dllimport)
@@ -86,7 +87,8 @@ static void getCommandLine(void)
   else
     {
       /* Call Term Management for NW and NWNI to get a string */
-      __CommandLine = localeToUTF(TermReadAndProcess());
+               char szTempUTF[bsiz];
+      __CommandLine = localeToUTF(TermReadAndProcess(), szTempUTF);
     }
 }
 
index 2b91b88..e89b17c 100644 (file)
@@ -450,9 +450,10 @@ char *TerminalGetString(char *prompt)
                        }
                        else
                        {
+                               char szTempUTF[bsiz];
                                char *line = getCurrentLine();
                                TerminalPutc('\n');
-                               appendLineToScilabHistory(localeToUTF(line));
+                               appendLineToScilabHistory(localeToUTF(line, szTempUTF));
                                return line;
                        }
                }
index 2800a66..cb575d5 100644 (file)
@@ -24,7 +24,7 @@
 #include "TermPosition.h"
 #include "../../../windows_tools/src/c/scilab_windows/console.h"
 /*--------------------------------------------------------------------------*/
-static int CURRENT_MAX_LINE_SIZE = 4096;
+static int CURRENT_MAX_LINE_SIZE = bsiz;
 static char *cur_line = NULL;  /* current contents of the line */      
 static char *currentPrompt = NULL;
 static int cur_pos = 0;                /* current position of the cursor */
@@ -213,8 +213,9 @@ void moveBackHistory(void)
 
        if (newline)
        {
+               char szLocale[bsiz];
                clearCurrentLine();
-               copyLine(UTFToLocale(newline));
+               copyLine(UTFToLocale(newline, szLocale));
                FREE(newline);
                newline = NULL;
        }
@@ -237,8 +238,9 @@ void moveForwardHistory(void)
 
        if (newline)
        {
+               char szLocale[bsiz];
                clearCurrentLine();
-               copyLine(UTFToLocale(newline));
+               copyLine(UTFToLocale(newline, szLocale));
                FREE(newline);
                newline = NULL;
        }
@@ -424,7 +426,8 @@ void putLineSearchedHistory(void)
 
        if (line)
        {
-               copyLine(UTFToLocale(line));
+               char szLocale[bsiz];
+               copyLine(UTFToLocale(line, szLocale));
                FREE(line);
                line = NULL;
        }