mgetl does not try to read file as UTF-16 in binary mode 01/16901/2
Antoine ELIAS [Mon, 27 Jul 2015 14:00:04 +0000 (16:00 +0200)]
Change-Id: I06fe5f9ba811ab1355df03722b463d008c098e13

scilab/modules/fileio/sci_gateway/cpp/sci_mopen.cpp
scilab/modules/fileio/src/cpp/mgetl.cpp

index 47e14f2..190032e 100644 (file)
@@ -35,7 +35,7 @@ Function::ReturnValue sci_mopen(typed_list &in, int _iRetCount, typed_list &out)
     int iErr                = 0;
     int iID                 = 0;
     wchar_t* pstFilename    = NULL;
-    const wchar_t* pstMode        = L"rb";
+    const wchar_t* pstMode  = L"rb";
     int iSwap               = 0;
 
     //check output parameters
index 7125aab..31ce41f 100644 (file)
@@ -251,27 +251,18 @@ wchar_t **mgetl(int fd, int nbLinesIn, int *nbLinesOut, int *ierr)
 /*--------------------------------------------------------------------------*/
 wchar_t* getLine(wchar_t* _pstLine, int _iLineSize, types::File* _pFile)
 {
-    if (_pFile->getFileModeAsInt() % 2 == 1)
+    char* pstTemp = (char*)MALLOC(sizeof(char) * _iLineSize);
+    if (fgets(pstTemp, _iLineSize, _pFile->getFiledesc()) == NULL)
     {
-        //binary mode
-        return fgetws(_pstLine, _iLineSize, _pFile->getFiledesc());
-    }
-    else
-    {
-        char* pstTemp = (char*)MALLOC(sizeof(char) * _iLineSize);
-        if (fgets(pstTemp, _iLineSize, _pFile->getFiledesc()) == NULL)
-        {
-            FREE(pstTemp);
-            return NULL;
-        }
-        //        char* pstUtf = convertAnsiToUtf(pstTemp);
-        wchar_t* pstTempWide = to_wide_string(pstTemp);
-        wcscpy(_pstLine, pstTempWide);
-        //FREE(pstUtf);
         FREE(pstTemp);
-        FREE(pstTempWide);
-        return _pstLine;
+        return NULL;
     }
+
+    wchar_t* pstTempWide = to_wide_string(pstTemp);
+    wcscpy(_pstLine, pstTempWide);
+    FREE(pstTemp);
+    FREE(pstTempWide);
+    return _pstLine;
 }
 /*--------------------------------------------------------------------------*/
 wchar_t *removeEOL(wchar_t *_inString)