summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine ELIAS <antoine.elias@scilab-enterprises.com>2016-11-10 08:31:52 +0100
committerAntoine ELIAS <antoine.elias@scilab-enterprises.com>2016-11-10 08:31:52 +0100
commit095a8a49ba05217b165c987d1bcdddc75a326878 (patch)
tree3f90627e212fd592ace9de4e9dbb986e771a48e9
parent86abdf992c0c44e13f1044af46d26cddd9b9d8f2 (diff)
downloadscilab-095a8a49ba05217b165c987d1bcdddc75a326878.zip
scilab-095a8a49ba05217b165c987d1bcdddc75a326878.tar.gz
utf: io 2
Change-Id: If460feec9a3f9f9ba93d5e6f5f69d21879dce429
-rw-r--r--scilab/modules/io/includes/getenvc.h1
-rw-r--r--scilab/modules/io/includes/setenvc.h1
-rw-r--r--scilab/modules/io/includes/systemc.h7
-rw-r--r--scilab/modules/io/sci_gateway/cpp/sci_genlib.cpp4
-rw-r--r--scilab/modules/io/src/c/Scilab_Windows_Import.def1
-rw-r--r--scilab/modules/io/src/c/getenvc.c91
-rw-r--r--scilab/modules/io/src/c/systemc.c14
-rw-r--r--scilab/modules/io/src/cpp/loadlib.cpp1
8 files changed, 23 insertions, 97 deletions
diff --git a/scilab/modules/io/includes/getenvc.h b/scilab/modules/io/includes/getenvc.h
index 82caa3a..ecf5a9a 100644
--- a/scilab/modules/io/includes/getenvc.h
+++ b/scilab/modules/io/includes/getenvc.h
@@ -35,7 +35,6 @@ IO_IMPEXP void getenvc(int *ierr, const char *var, char *buf, int *buflen, int *
35* @return path found 35* @return path found
36*/ 36*/
37IO_IMPEXP char *searchEnv(const char *name, const char *env_var); 37IO_IMPEXP char *searchEnv(const char *name, const char *env_var);
38IO_IMPEXP wchar_t* searchEnvW(const wchar_t* _pwstName, const wchar_t* _pwstEnv);
39 38
40 39
41 40
diff --git a/scilab/modules/io/includes/setenvc.h b/scilab/modules/io/includes/setenvc.h
index ad23b75..97fea54 100644
--- a/scilab/modules/io/includes/setenvc.h
+++ b/scilab/modules/io/includes/setenvc.h
@@ -25,7 +25,6 @@
25 * @return FALSE if there is a problem otherwise TRUE 25 * @return FALSE if there is a problem otherwise TRUE
26 */ 26 */
27IO_IMPEXP BOOL setenvc(const char *string, const char *value); 27IO_IMPEXP BOOL setenvc(const char *string, const char *value);
28IO_IMPEXP BOOL setenvcW(const wchar_t *string, const wchar_t *value);
29 28
30#endif /* __SETENVC_H__ */ 29#endif /* __SETENVC_H__ */
31/*--------------------------------------------------------------------------*/ 30/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/io/includes/systemc.h b/scilab/modules/io/includes/systemc.h
index c903156..018f53d 100644
--- a/scilab/modules/io/includes/systemc.h
+++ b/scilab/modules/io/includes/systemc.h
@@ -20,11 +20,4 @@
20 */ 20 */
21IO_IMPEXP int systemc(char *command, int *stat); 21IO_IMPEXP int systemc(char *command, int *stat);
22 22
23/**
24 * Execute a command by the system
25 * @param[in] command the command
26 * @param[out] the status of the operation
27 */
28IO_IMPEXP int systemcW(wchar_t* _pstCommand, int *stat);
29
30#endif 23#endif
diff --git a/scilab/modules/io/sci_gateway/cpp/sci_genlib.cpp b/scilab/modules/io/sci_gateway/cpp/sci_genlib.cpp
index 1225234..05ec8f4 100644
--- a/scilab/modules/io/sci_gateway/cpp/sci_genlib.cpp
+++ b/scilab/modules/io/sci_gateway/cpp/sci_genlib.cpp
@@ -181,7 +181,7 @@ types::Function::ReturnValue sci_genlib(types::typed_list &in, int _iRetCount, t
181 181
182 if (bVerbose) 182 if (bVerbose)
183 { 183 {
184 os_sprintf(pstVerbose, _("-- Creation of [%ls] (Macros) --\n"), pstLibName); 184 os_sprintf(pstVerbose, _("-- Creation of [%s] (Macros) --\n"), pstLibName);
185 185
186 //save current prompt mode 186 //save current prompt mode
187 int oldVal = ConfigVariable::getPromptMode(); 187 int oldVal = ConfigVariable::getPromptMode();
@@ -264,7 +264,7 @@ types::Function::ReturnValue sci_genlib(types::typed_list &in, int _iRetCount, t
264 264
265 if (bVerbose) 265 if (bVerbose)
266 { 266 {
267 sciprint(_("%ls: Processing file: %ls\n"), L"genlib", pstPath[k]); 267 sciprint(_("%s: Processing file: %s\n"), "genlib", pstPath[k]);
268 } 268 }
269 269
270 Parser parser; 270 Parser parser;
diff --git a/scilab/modules/io/src/c/Scilab_Windows_Import.def b/scilab/modules/io/src/c/Scilab_Windows_Import.def
index 0d92ba9..7bd23a9 100644
--- a/scilab/modules/io/src/c/Scilab_Windows_Import.def
+++ b/scilab/modules/io/src/c/Scilab_Windows_Import.def
@@ -6,4 +6,3 @@ EXPORTS
6; scilab_windows 6; scilab_windows
7; 7;
8CallWindowsShell 8CallWindowsShell
9CallWindowsShellW
diff --git a/scilab/modules/io/src/c/getenvc.c b/scilab/modules/io/src/c/getenvc.c
index 0643f07..8c064a0 100644
--- a/scilab/modules/io/src/c/getenvc.c
+++ b/scilab/modules/io/src/c/getenvc.c
@@ -34,12 +34,10 @@ static void searchenv_others(const char *filename, const char *varname,
34void getenvc(int *ierr, const char *var, char *buf, int *buflen, int *iflag) 34void getenvc(int *ierr, const char *var, char *buf, int *buflen, int *iflag)
35{ 35{
36#ifdef _MSC_VER 36#ifdef _MSC_VER
37 wchar_t* wbuf = NULL; 37 DWORD iLen = GetEnvironmentVariableA(var, NULL, 0);
38 wchar_t *wvar = to_wide_string(var);
39 char* temp = NULL;
40 DWORD iLen = GetEnvironmentVariableW(wvar, NULL, 0);
41 38
42 *ierr = 0; 39 *ierr = 0;
40 char* tmpbuf = NULL;
43 41
44 if (iLen == 0) 42 if (iLen == 0)
45 { 43 {
@@ -48,37 +46,31 @@ void getenvc(int *ierr, const char *var, char *buf, int *buflen, int *iflag)
48 sciprint(_("Undefined environment variable %s.\n"), var); 46 sciprint(_("Undefined environment variable %s.\n"), var);
49 } 47 }
50 48
51 FREE(wvar);
52 *ierr = 1; 49 *ierr = 1;
53 return; 50 return;
54 } 51 }
55 else 52
53 tmpbuf = (char*)MALLOC(sizeof(char) * iLen);
54 if (GetEnvironmentVariableA(var, tmpbuf, iLen) == 0)
56 { 55 {
57 wbuf = (wchar_t*)MALLOC(sizeof(wchar_t) * iLen); 56 if (*iflag == 1)
58 if (GetEnvironmentVariableW(wvar, wbuf, iLen) == 0)
59 { 57 {
60 if (*iflag == 1) 58 sciprint(_("Undefined environment variable %s.\n"), var);
61 {
62 sciprint(_("Undefined environment variable %s.\n"), var);
63 }
64
65 FREE(wbuf);
66 FREE(wvar);
67 *ierr = 1;
68 return;
69 } 59 }
60
61 *ierr = 1;
62 FREE(tmpbuf);
63 return;
70 } 64 }
71 65
72 temp = wide_string_to_UTF8(wbuf); 66
73 FREE(wbuf); 67 *buflen = (int)strlen(tmpbuf);
74 FREE(wvar);
75 *buflen = (int)strlen(temp);
76 if (buf) 68 if (buf)
77 { 69 {
78 strcpy(buf, temp); 70 strcpy(buf, tmpbuf);
71 FREE(tmpbuf)
79 } 72 }
80 73
81 FREE(temp);
82#else 74#else
83 char *locale = NULL; 75 char *locale = NULL;
84 locale = getenv(var); 76 locale = getenv(var);
@@ -193,24 +185,16 @@ char *searchEnv(const char *name, const char *env_var)
193 185
194#if _MSC_VER 186#if _MSC_VER
195 { 187 {
196 wchar_t *wname = NULL; 188 char fullpath[PATH_MAX];
197 wchar_t *wenv_var = NULL;
198 wchar_t wfullpath[PATH_MAX];
199 189
200 wname = to_wide_string((char*)name); 190 strcpy(fullpath, "");
201 wenv_var = to_wide_string((char*)env_var);
202 191
203 wcscpy(wfullpath, L""); 192 _searchenv(name, env_var, fullpath);
204 193
205 _wsearchenv(wname, wenv_var, wfullpath); 194 if (strlen(fullpath) > 0)
206
207 if (wcslen(wfullpath) > 0)
208 { 195 {
209 buffer = wide_string_to_UTF8(wfullpath); 196 buffer = os_strdup(fullpath);
210 } 197 }
211
212 FREE(wname);
213 FREE(wenv_var);
214 } 198 }
215#else 199#else
216 searchenv_others(name, env_var, fullpath); 200 searchenv_others(name, env_var, fullpath);
@@ -222,39 +206,4 @@ char *searchEnv(const char *name, const char *env_var)
222 return buffer; 206 return buffer;
223} 207}
224/*--------------------------------------------------------------------------*/ 208/*--------------------------------------------------------------------------*/
225wchar_t* searchEnvW(const wchar_t* _pwstName, const wchar_t* _pwstEnv)
226{
227 wchar_t* pwstRet = NULL;
228 wchar_t pwstFullpath[PATH_MAX];
229
230#if !_MSC_VER
231 char* pstName = wide_string_to_UTF8(_pwstName);
232 char* pstEnv = wide_string_to_UTF8(_pwstEnv);
233 char pstFullpath[PATH_MAX];
234#endif
235
236 wcscpy(pwstFullpath, L"");
237
238#if _MSC_VER
239 {
240 _wsearchenv(_pwstName, _pwstEnv, pwstFullpath);
241
242 if (wcslen(pwstFullpath) > 0)
243 {
244 pwstRet = os_wcsdup(pwstFullpath);
245 }
246 }
247#else
248 searchenv_others(pstName, pstEnv, pstFullpath);
249 if (strlen(pstFullpath) > 0)
250 {
251 pwstRet = to_wide_string(pstFullpath);
252 }
253
254 FREE(pstName);
255 FREE(pstEnv);
256#endif
257 return pwstRet;
258}
259/*--------------------------------------------------------------------------*/
260 209
diff --git a/scilab/modules/io/src/c/systemc.c b/scilab/modules/io/src/c/systemc.c
index 6916ec2..9bc34f9 100644
--- a/scilab/modules/io/src/c/systemc.c
+++ b/scilab/modules/io/src/c/systemc.c
@@ -35,17 +35,3 @@ int systemc(char *command, int *stat)
35 return 0; 35 return 0;
36} 36}
37/*--------------------------------------------------------------------------*/ 37/*--------------------------------------------------------------------------*/
38int systemcW(wchar_t* _pstCommand, int *stat)
39{
40#ifdef _MSC_VER
41 *stat = CallWindowsShellW(_pstCommand);
42#else
43 char* pstTemp = wide_string_to_UTF8(_pstCommand);
44 int status = system(pstTemp);
45 FREE(pstTemp);
46 /* provide exit value of the child */
47 *stat = WEXITSTATUS(status);
48#endif
49 return 0;
50}
51/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/io/src/cpp/loadlib.cpp b/scilab/modules/io/src/cpp/loadlib.cpp
index 57ec0fd..f4d83a2 100644
--- a/scilab/modules/io/src/cpp/loadlib.cpp
+++ b/scilab/modules/io/src/cpp/loadlib.cpp
@@ -152,6 +152,7 @@ int parseLibFile(const std::string& _stXML, MacroInfoList& info, std::string& li
152 { 152 {
153 /* we found the tag name */ 153 /* we found the tag name */
154 stLibName = (const char*)attrib->children->content; 154 stLibName = (const char*)attrib->children->content;
155 libname = stLibName;
155 xmlXPathFreeObject(xpathObj); 156 xmlXPathFreeObject(xpathObj);
156 } 157 }
157 else 158 else