=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/builtin/file.c,v retrieving revision 1.31 retrieving revision 1.36 diff -u -p -r1.31 -r1.36 --- OpenXM_contrib2/asir2000/builtin/file.c 2014/05/12 02:27:49 1.31 +++ OpenXM_contrib2/asir2000/builtin/file.c 2017/06/12 06:22:50 1.36 @@ -45,20 +45,20 @@ * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. * - * $OpenXM: OpenXM_contrib2/asir2000/builtin/file.c,v 1.30 2014/04/02 22:08:29 ohara Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/builtin/file.c,v 1.35 2017/06/10 05:32:24 noro Exp $ */ #include "ca.h" #include "parse.h" #include "ox.h" #include "base.h" -#if !defined(VISUAL) +#if !defined(VISUAL) && !defined(__MINGW32__) #include "unistd.h" #endif #if defined(PARI) #include "genpari.h" #endif -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) #include #include #include @@ -68,6 +68,8 @@ #define R_OK 0x04 #endif +void Psprintf(NODE,STRING *); + void Pget_rootdir(); void Paccess(),Premove_file(); void Pbsave_enc(), Pbload_enc(); @@ -169,7 +171,7 @@ void Popen_file(NODE arg,Q *rp) asir_assert(ARG1(arg),O_STR,"open_file"); fp = fopen(name,BDY((STRING)ARG1(arg))); } else - fp = fopen(name,"r"); + fp = fopen(name,"rb"); } if ( !fp ) { sprintf(errbuf,"open_file : cannot open \"%s\"",name); @@ -239,6 +241,12 @@ void Pget_line(NODE arg,STRING *rp) fsetpos(fp,&head); str = (char *)MALLOC_ATOMIC(j+1); fgets(str,j+1,fp); + for ( i = 0; i < j; i++ ) + if ( str[i] == '\r' ) { + str[i] = '\n'; + str[i+1] = 0; + break; + } MKSTR(*rp,str); } else error("get_line : invalid argument"); @@ -506,7 +514,7 @@ void Pbload_cmo(NODE arg,Obj *rp) static struct oSTRING rootdir; -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) void get_rootdir(char *name,int len) { LONG ret; @@ -589,7 +597,7 @@ void Pgetpid(Q *rp) { int id; -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) id = GetCurrentProcessId(); #else id = getpid(); @@ -699,7 +707,7 @@ void Paccess(NODE arg,Q *rp) *rp = 0; } -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) int process_id() { return GetCurrentProcessId();