From f07b08539381fd928fc3c4734bf5429777e5077e Mon Sep 17 00:00:00 2001 From: cristy Date: Fri, 23 Sep 2011 21:36:56 +0000 Subject: [PATCH] --- MagickCore/utility-private.h | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/MagickCore/utility-private.h b/MagickCore/utility-private.h index d3f8573bc..c90186c8a 100644 --- a/MagickCore/utility-private.h +++ b/MagickCore/utility-private.h @@ -73,6 +73,9 @@ static inline FILE *fopen_utf8(const char *path,const char *mode) FILE *file; + int + count; + WCHAR *mode_wide, *path_wide; @@ -81,17 +84,17 @@ static inline FILE *fopen_utf8(const char *path,const char *mode) count=MultiByteToWideChar(CP_UTF8,0,path,-1,NULL,0); path_wide=(WCHAR *) AcquireQuantumMemory(count,sizeof(*path_wide)); if (path_wide == (WCHAR *) NULL) - return(-1); + return((FILE *) NULL); count=MultiByteToWideChar(CP_UTF8,0,path,-1,path_wide,count); count=MultiByteToWideChar(CP_UTF8,0,mode,-1,NULL,0); mode_wide=(WCHAR *) AcquireQuantumMemory(count,sizeof(*mode_wide)); if (mode_wide == (WCHAR *) NULL) { path_wide=RelinquishMagickMemory(path_wide); - return(-1); + return((FILE *) NULL); } count=MultiByteToWideChar(CP_UTF8,0,mode,-1,mode_wide,count); - file=_wfopen(path_wide,mode_width); + file=_wfopen(path_wide,mode_wide); mode_wide=RelinquishMagickMemory(mode_wide); path_wide=RelinquishMagickMemory(path_wide); return(file); @@ -130,6 +133,9 @@ static inline FILE *popen_utf8(const char *command,const char *type) FILE *file; + int + count; + WCHAR *type_wide, *command_wide; @@ -138,19 +144,19 @@ static inline FILE *popen_utf8(const char *command,const char *type) count=MultiByteToWideChar(CP_UTF8,0,command,-1,NULL,0); command_wide=(WCHAR *) AcquireQuantumMemory(count,sizeof(*command_wide)); if (command_wide == (WCHAR *) NULL) - return(-1); + return((FILE *) NULL); count=MultiByteToWideChar(CP_UTF8,0,command,-1,command_wide,count); count=MultiByteToWideChar(CP_UTF8,0,type,-1,NULL,0); type_wide=(WCHAR *) AcquireQuantumMemory(count,sizeof(*type_wide)); if (type_wide == (WCHAR *) NULL) { command_wide=RelinquishMagickMemory(command_wide); - return(-1); + return((FILE *) NULL); } count=MultiByteToWideChar(CP_UTF8,0,type,-1,type_wide,count); - file=_wpopen(path_wide,type_width); + file=_wpopen(command_wide,type_wide); type_wide=RelinquishMagickMemory(type_wide); - path_wide=RelinquishMagickMemory(path_wide); + command_wide=RelinquishMagickMemory(command_wide); return(file); #endif } @@ -184,10 +190,8 @@ static inline int rename_utf8(const char *source,const char *destination) #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) || defined(__MINGW32__) return(rename(source,destination)); #else - FILE - *file; - int + count, status; WCHAR @@ -209,9 +213,9 @@ static inline int rename_utf8(const char *source,const char *destination) return(-1); } count=MultiByteToWideChar(CP_UTF8,0,destination,-1,destination_wide,count); - status=_wrename(path_wide,destination_width); + status=_wrename(source_wide,destination_wide); destination_wide=RelinquishMagickMemory(destination_wide); - path_wide=RelinquishMagickMemory(path_wide); + source_wide=RelinquishMagickMemory(source_wide); return(status); #endif } @@ -234,7 +238,7 @@ static inline int stat_utf8(const char *path,struct stat *attributes) if (path_wide == (WCHAR *) NULL) return(-1); count=MultiByteToWideChar(CP_UTF8,0,path,-1,path_wide,count); - status=_wstat(path_wide,attributes); + status=wstat(path_wide,attributes); path_wide=RelinquishMagickMemory(path_wide); return(status); #endif -- 2.40.0