Kouhei Sutou
null+****@clear*****
Thu Apr 16 21:25:33 JST 2015
Kouhei Sutou 2015-04-16 21:25:33 +0900 (Thu, 16 Apr 2015) New Revision: e2f27d986f9d08f2d6e6a522ef8d5460fda81bb2 https://github.com/groonga/groonga/commit/e2f27d986f9d08f2d6e6a522ef8d5460fda81bb2 Message: windows: use _fsopen() instead of fopen_s() Because fopen_s() doesn't support shared open. Modified files: include/groonga/portability.h lib/ctx.c lib/logger.c lib/mrb.c Modified: include/groonga/portability.h (+2 -6) =================================================================== --- include/groonga/portability.h 2015-04-16 19:11:10 +0900 (74cd25d) +++ include/groonga/portability.h 2015-04-16 21:25:33 +0900 (aabcbba) @@ -68,13 +68,9 @@ #endif /* WIN32 */ #ifdef WIN32 -# define grn_fopen(file, name, mode) do { \ - if (fopen_s(&file, name, mode) != 0) { \ - file = NULL; \ - } \ - } while (0) +# define grn_fopen(name, mode) _fsopen((name), (mode), _SH_DENYNO) #else /* WIN32 */ -# define grn_fopen(file, name, mode) (file) = fopen((name), (mode)) +# define grn_fopen(name, mode) fopen((name), (mode)) #endif /* WIN32 */ #ifdef WIN32 Modified: lib/ctx.c (+5 -1) =================================================================== --- lib/ctx.c 2015-04-16 19:11:10 +0900 (c0efd00) +++ lib/ctx.c 2015-04-16 21:25:33 +0900 (4ed5dae) @@ -35,6 +35,10 @@ # include <netinet/in.h> #endif /* HAVE_NETINET_IN_H */ +#ifdef WIN32 +# include <share.h> +#endif /* WIN32 */ + #if defined(HAVE__LOCALTIME64_S) && defined(__GNUC__) # ifdef _WIN64 # define localtime_s(tm, time) _localtime64_s(tm, time) @@ -785,7 +789,7 @@ check_overcommit_memory(grn_ctx *ctx) { FILE *file; int value; - grn_fopen(file, "/proc/sys/vm/overcommit_memory", "r"); + file = grn_fopen("/proc/sys/vm/overcommit_memory", "r"); if (!file) { return; } value = fgetc(file); if (value != '1') { Modified: lib/logger.c (+6 -2) =================================================================== --- lib/logger.c 2015-04-16 19:11:10 +0900 (acb71b1) +++ lib/logger.c 2015-04-16 21:25:33 +0900 (e634de9) @@ -25,6 +25,10 @@ #include <sys/stat.h> #ifdef WIN32 +# include <share.h> +#endif /* WIN32 */ + +#ifdef WIN32 # define fileno(file) _fileno(file) #endif @@ -65,7 +69,7 @@ default_logger_log(grn_ctx *ctx, grn_log_level level, if (default_logger_path) { CRITICAL_SECTION_ENTER(default_logger_lock); if (!default_logger_file) { - grn_fopen(default_logger_file, default_logger_path, "a"); + default_logger_file = grn_fopen(default_logger_path, "a"); default_logger_size = 0; if (default_logger_file) { struct stat stat; @@ -330,7 +334,7 @@ default_query_logger_log(grn_ctx *ctx, unsigned int flag, if (default_query_logger_path) { CRITICAL_SECTION_ENTER(default_query_logger_lock); if (!default_query_logger_file) { - grn_fopen(default_query_logger_file, default_query_logger_path, "a"); + default_query_logger_file = grn_fopen(default_query_logger_path, "a"); default_query_logger_size = 0; if (default_query_logger_file) { struct stat stat; Modified: lib/mrb.c (+6 -2) =================================================================== --- lib/mrb.c 2015-04-16 19:11:10 +0900 (ea17f35) +++ lib/mrb.c 2015-04-16 21:25:33 +0900 (3519e48) @@ -1,6 +1,6 @@ /* -*- c-basic-offset: 2 -*- */ /* - Copyright(C) 2013 Brazil + Copyright(C) 2013-2015 Brazil This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -28,6 +28,10 @@ #include <ctype.h> +#ifdef WIN32 +# include <share.h> +#endif /* WIN32 */ + #define BUFFER_SIZE 2048 #define E_LOAD_ERROR (mrb_class_get(mrb, "LoadError")) @@ -145,7 +149,7 @@ grn_mrb_load(grn_ctx *ctx, const char *path) return mrb_nil_value(); } - grn_fopen(file, expanded_path, "r"); + file = grn_fopen(expanded_path, "r"); if (!file) { char message[BUFFER_SIZE]; mrb_value exception; -------------- next part -------------- HTML����������������������������...Télécharger