utf: windows_tools 2 61/18661/1
Antoine ELIAS [Thu, 10 Nov 2016 07:25:19 +0000 (08:25 +0100)]
Change-Id: I32744575877cafee7ac9db32902f3f12dbf31040

scilab/modules/windows_tools/sci_gateway/cpp/sci_winopen.cpp
scilab/modules/windows_tools/src/c/scilab_windows/FilesAssociations.c
scilab/modules/windows_tools/src/cpp/scilab_windows/SetScilabEnvironmentVariables.cpp
scilab/modules/windows_tools/src/cpp/scilab_windows/getScilabDirectory.cpp

index 8482f44..d01f86a 100644 (file)
@@ -57,7 +57,7 @@ types::Function::ReturnValue sci_winopen(types::typed_list &in, int _iRetCount,
     }
     else
     {
-        Scierror(999, _("%s: Cannot open file %ls.\n"), fname.data(), pS->get()[0]);
+        Scierror(999, _("%s: Cannot open file %s.\n"), fname.data(), pS->get()[0]);
         return types::Function::Error;
     }
 
index 8caa862..2152274 100644 (file)
@@ -152,7 +152,7 @@ int CommandByFileExtension(char *fichier, int OpenCode, char *Cmd)
             {
                 if (!HaveAnotherWindowScilab() || haveMutexClosingScilab())
                 {
-                    if (with_module(L"scinotes"))
+                    if (with_module("scinotes"))
                     {
                         wsprintf(Cmd, MSG_SCIMSG5_EDITOR, PathWScilex, FinalFileName);
                     }
@@ -166,7 +166,7 @@ int CommandByFileExtension(char *fichier, int OpenCode, char *Cmd)
                 {
                     char *ScilabDestination = NULL;
 
-                    if (with_module(L"scinotes"))
+                    if (with_module("scinotes"))
                     {
                         wsprintf(Cmd, MSG_SCIMSG6_EDITOR, FinalFileName);
                     }
@@ -185,7 +185,7 @@ int CommandByFileExtension(char *fichier, int OpenCode, char *Cmd)
                     }
                     else
                     {
-                        if (with_module(L"scinotes"))
+                        if (with_module("scinotes"))
                         {
                             wsprintf(Cmd, MSG_SCIMSG5_EDITOR, PathWScilex, FinalFileName);
                         }
@@ -213,7 +213,7 @@ int CommandByFileExtension(char *fichier, int OpenCode, char *Cmd)
                         ExtensionFileIntoLowerCase(FinalFileName);
                         if (!HaveAnotherWindowScilab() || haveMutexClosingScilab())
                         {
-                            if (with_module(L"xcos"))
+                            if (with_module("xcos"))
                             {
                                 wsprintf(Cmd, MSG_SCIMSG2_XCOS, PathWScilex, FinalFileName);
                             }
@@ -227,7 +227,7 @@ int CommandByFileExtension(char *fichier, int OpenCode, char *Cmd)
                         {
                             char *ScilabDestination = NULL;
 
-                            if (with_module(L"xcos"))
+                            if (with_module("xcos"))
                             {
                                 wsprintf(Cmd, MSG_SCIMSG3_XCOS, FinalFileName);
                             }
@@ -246,7 +246,7 @@ int CommandByFileExtension(char *fichier, int OpenCode, char *Cmd)
                             }
                             else
                             {
-                                if (with_module(L"xcos"))
+                                if (with_module("xcos"))
                                 {
                                     wsprintf(Cmd, MSG_SCIMSG2_XCOS, PathWScilex, FinalFileName);
                                 }
index d0e65a1..bd07cb4 100644 (file)
@@ -117,33 +117,25 @@ BOOL Set_SCI_PATH(char *DefaultPath)
 /*--------------------------------------------------------------------------*/
 BOOL Set_HOME_PATH(char *DefaultPath)
 {
-    wchar_t *wHOME = _wgetenv(L"HOME");
-    if (wHOME == NULL)
+    char *HOME = getenv("HOME");
+    if (HOME == NULL)
     {
-        wchar_t *wUserProfile = _wgetenv(L"USERPROFILE");
-        if (wUserProfile)
+        char* UserProfile = getenv("USERPROFILE");
+        if (UserProfile)
         {
-            return SetEnvironmentVariableW(L"HOME", wUserProfile);
+            return SetEnvironmentVariableA("HOME", UserProfile);
         }
         else
         {
             /* if USERPROFILE is not defined , we use default profile */
-            wchar_t *wAllUsersProfile = _wgetenv(L"ALLUSERSPROFILE");
-            if (wAllUsersProfile)
+            char *AllUsersProfile = getenv("ALLUSERSPROFILE");
+            if (AllUsersProfile)
             {
-                return SetEnvironmentVariableW(L"HOME", wUserProfile);
+                return SetEnvironmentVariableA("HOME", UserProfile);
             }
             else
             {
-                BOOL bRes = FALSE;
-                wchar_t *wDefault = to_wide_string(DefaultPath);
-                if (wDefault)
-                {
-                    bRes = SetEnvironmentVariableW(L"HOME", wDefault);
-                    FREE(wDefault);
-                    wDefault = NULL;
-                }
-                return bRes;
+                return SetEnvironmentVariableA("HOME", DefaultPath);
             }
         }
     }
index ccf5c8c..26facf1 100644 (file)
@@ -26,58 +26,58 @@ extern "C"
 char *getScilabDirectory(BOOL UnixStyle)
 {
     char *SciPathName = NULL;
-    wchar_t* wcSciPathName = NULL;
-    wchar_t ScilabModuleName[MAX_PATH + 1];
-    wchar_t drive[_MAX_DRIVE];
-    wchar_t dir[_MAX_DIR];
-    wchar_t fname[_MAX_FNAME];
-    wchar_t ext[_MAX_EXT];
-    wchar_t *DirTmp = NULL;
+    char* cSciPathName = NULL;
+    char ScilabModuleName[MAX_PATH + 1];
+    char drive[_MAX_DRIVE];
+    char dir[_MAX_DIR];
+    char fname[_MAX_FNAME];
+    char ext[_MAX_EXT];
+    char *DirTmp = NULL;
 
 
-    if (!GetModuleFileNameW ((HINSTANCE)GetModuleHandleW(L"core"), (wchar_t*) ScilabModuleName, MAX_PATH))
+    if (!GetModuleFileNameA((HINSTANCE)GetModuleHandleA("core"), ScilabModuleName, MAX_PATH))
     {
         return NULL;
     }
 
-    os_wsplitpath(ScilabModuleName, drive, dir, fname, ext);
+    os_splitpath(ScilabModuleName, drive, dir, fname, ext);
 
-    if (dir[wcslen(dir) - 1] == L'\\')
+    if (dir[strlen(dir) - 1] == '\\')
     {
-        dir[wcslen(dir) - 1] = L'\0';
+        dir[strlen(dir) - 1] = '\0';
     }
 
-    DirTmp = wcsrchr (dir, L'\\');
+    DirTmp = strrchr (dir, '\\');
 
-    if (wcslen(dir) - wcslen(DirTmp) > 0)
+    if (strlen(dir) - strlen(DirTmp) > 0)
     {
-        dir[wcslen(dir) - wcslen(DirTmp)] = L'\0';
+        dir[strlen(dir) - strlen(DirTmp)] = '\0';
     }
     else
     {
         return NULL;
     }
 
-    wcSciPathName = (wchar_t*)MALLOC((int)( wcslen(drive) + wcslen(dir) + 5) * sizeof(wchar_t));
-    if (wcSciPathName)
+    cSciPathName = (char*)MALLOC((int)(strlen(drive) + strlen(dir) + 5) * sizeof(char));
+    if (cSciPathName)
     {
-        _wmakepath(wcSciPathName, drive, dir, NULL, NULL);
+        _makepath(cSciPathName, drive, dir, NULL, NULL);
         if ( UnixStyle )
         {
             int i = 0;
-            for (i = 0; i < (int)wcslen(wcSciPathName); i++)
+            for (i = 0; i < (int)strlen(cSciPathName); i++)
             {
-                if (wcSciPathName[i] == L'\\')
+                if (cSciPathName[i] == '\\')
                 {
-                    wcSciPathName[i] = L'/';
+                    cSciPathName[i] = '/';
                 }
             }
         }
-        wcSciPathName[wcslen(wcSciPathName) - 1] = '\0';
+        cSciPathName[strlen(cSciPathName) - 1] = '\0';
 
-        SciPathName = wide_string_to_UTF8(wcSciPathName);
-        FREE(wcSciPathName);
-        wcSciPathName = NULL;
+        SciPathName = os_strdup(cSciPathName);
+        FREE(cSciPathName);
+        cSciPathName = NULL;
     }
 
     if (SciPathName)