Skip to content

Commit

Permalink
Fixes for #1294
Browse files Browse the repository at this point in the history
- in MinGW/MSVC/Windows open the parsed file in "rt" mode 
  Parser/antlr-3.2/runtime/C/src/antlr3filestream.c
- in MinGW/MSVC/Windows open the written file in "wt" mode
  Compiler/runtime/printimpl.c
  Compiler/runtime/systemimpl.c


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@6207 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Sep 24, 2010
1 parent a7dfd92 commit 4fc3e7b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Compiler/runtime/printimpl.c
Expand Up @@ -279,12 +279,17 @@ RML_END_LABEL

RML_BEGIN_LABEL(Print__writeBuf)
{
#if defined(__MINGW32__) || defined(_MSC_VER)
char *fileOpenMode = "wt"; /* on Windows do translation so that \n becomes \r\n */
#else
char *fileOpenMode = "wb"; /* on Unixes don't bother, do it binary mode */
#endif
char * filename = RML_STRINGDATA(rmlA0);
FILE * file = NULL;
/* check if we have something to write */
/* open the file */
/* adrpo: 2010-09-22 open the file in BINARY mode as otherwise \r\n becomes \r\r\n! */
file = fopen(filename,"wb");
file = fopen(filename,fileOpenMode);
if (file == NULL) {
char *c_tokens[1]={filename};
c_add_message(21, /* WRITING_FILE_ERROR */
Expand Down
7 changes: 6 additions & 1 deletion Compiler/runtime/systemimpl.c
Expand Up @@ -659,13 +659,18 @@ RML_END_LABEL

RML_BEGIN_LABEL(System__writeFile)
{
#if defined(__MINGW32__) || defined(_MSC_VER)
char *fileOpenMode = "wt"; /* on Windows do translation so that \n becomes \r\n */
#else
char *fileOpenMode = "wb"; /* on Unixes don't bother, do it binary mode */
#endif
char* data = RML_STRINGDATA(rmlA1);
char* filename = RML_STRINGDATA(rmlA0);
FILE * file = NULL;
int len = strlen(data); /* RML_HDRSTRLEN(RML_GETHDR(rmlA1)); */
int x = 0;
/* adrpo: 2010-09-22 open the file in BINARY mode as otherwise \r\n becomes \r\r\n! */
file = fopen(filename,"wb");
file = fopen(filename,fileOpenMode);
if (file == NULL) {
char *c_tokens[1]={filename};
c_add_message(21, /* WRITING_FILE_ERROR */
Expand Down

0 comments on commit 4fc3e7b

Please sign in to comment.