Skip to content

Commit b6843a0

Browse files
committed
patch 8.0.0840: MS-Windows: fopen() and open() prototypes are wrong
Problem: MS-Windows: fopen() and open() prototypes do not match the ones in the system header file. Can't build without FEAT_MBYTE. Solution: Add "const". Move macro to after including protoo.h.
1 parent fae4283 commit b6843a0

5 files changed

Lines changed: 13 additions & 11 deletions

File tree

src/macros.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,6 @@
191191
# ifndef WIN32
192192
# define mch_access(n, p) access((n), (p))
193193
# endif
194-
# if !(defined(FEAT_MBYTE) && defined(WIN3264))
195-
# define mch_fopen(n, p) fopen((n), (p))
196-
# endif
197194
# define mch_fstat(n, p) fstat((n), (p))
198195
# ifdef MSWIN /* has it's own mch_stat() function */
199196
# define mch_stat(n, p) vim_stat((n), (p))
@@ -223,10 +220,6 @@
223220
* but it is not recommended, because it can destroy indexes etc.
224221
*/
225222
# define mch_open(n, m, p) open(vms_fixfilename(n), (m), (p))
226-
# else
227-
# if !(defined(FEAT_MBYTE) && defined(WIN3264))
228-
# define mch_open(n, m, p) open((n), (m), (p))
229-
# endif
230223
# endif
231224
#endif
232225

src/os_win32.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6503,7 +6503,7 @@ mch_access(char *n, int p)
65036503
* Version of open() that may use UTF-16 file name.
65046504
*/
65056505
int
6506-
mch_open(char *name, int flags, int mode)
6506+
mch_open(const char *name, int flags, int mode)
65076507
{
65086508
/* _wopen() does not work with Borland C 5.5: creates a read-only file. */
65096509
# ifndef __BORLANDC__
@@ -6536,7 +6536,7 @@ mch_open(char *name, int flags, int mode)
65366536
* Version of fopen() that may use UTF-16 file name.
65376537
*/
65386538
FILE *
6539-
mch_fopen(char *name, char *mode)
6539+
mch_fopen(const char *name, const char *mode)
65406540
{
65416541
WCHAR *wn, *wm;
65426542
FILE *f = NULL;

src/proto/os_win32.pro

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ HINSTANCE find_imported_module_by_funcname(HINSTANCE hInst, const char *funcname
44
void *get_dll_import_func(HINSTANCE hInst, const char *funcname);
55
int dyn_libintl_init(void);
66
void dyn_libintl_end(void);
7+
int null_libintl_putenv(const char *envstring);
8+
int null_libintl_wputenv(const wchar_t *envstring);
79
void PlatformId(void);
810
void mch_setmouse(int on);
911
void mch_update_cursor(void);
@@ -56,8 +58,8 @@ int mch_wrename(WCHAR *wold, WCHAR *wnew);
5658
int mch_rename(const char *pszOldFile, const char *pszNewFile);
5759
char *default_shell(void);
5860
int mch_access(char *n, int p);
59-
int mch_open(char *name, int flags, int mode);
60-
FILE *mch_fopen(char *name, char *mode);
61+
int mch_open(const char *name, int flags, int mode);
62+
FILE *mch_fopen(const char *name, const char *mode);
6163
int mch_copy_file_attribute(char_u *from, char_u *to);
6264
int myresetstkoflw(void);
6365
int get_cmd_argsW(char ***argvp);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ static char *(features[]) =
769769

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
840,
772774
/**/
773775
839,
774776
/**/

src/vim.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2141,6 +2141,11 @@ typedef enum {
21412141
# define number_width(x) 7
21422142
#endif
21432143

2144+
/* This must come after including proto.h */
2145+
#if !(defined(FEAT_MBYTE) && defined(WIN3264))
2146+
# define mch_open(n, m, p) open((n), (m), (p))
2147+
# define mch_fopen(n, p) fopen((n), (p))
2148+
#endif
21442149

21452150
#include "globals.h" /* global variables and messages */
21462151

0 commit comments

Comments
 (0)