Kouhei Sutou
null+****@clear*****
Sun May 22 16:04:52 JST 2016
Kouhei Sutou 2016-05-22 16:04:52 +0900 (Sun, 22 May 2016) New Revision: 75a99a0e9dc6d27b88ff9e9aff54e83a13a543a3 https://github.com/groonga/groonga/commit/75a99a0e9dc6d27b88ff9e9aff54e83a13a543a3 Message: windows: fix a bug than 1 byte isn't written to log message Modified files: include/groonga/portability.h lib/logger.c Modified: include/groonga/portability.h (+8 -4) =================================================================== --- include/groonga/portability.h 2016-05-22 09:39:36 +0900 (5f56e39) +++ include/groonga/portability.h 2016-05-22 16:04:52 +0900 (d3720fb) @@ -134,16 +134,20 @@ #endif /* WIN32 */ #ifdef WIN32 -# define grn_snprintf(dest, dest_size, n, ...) \ - _snprintf_s((dest), (dest_size), (n) - 1, __VA_ARGS__) +# define grn_snprintf(dest, dest_size, n, ...) do { \ + _snprintf_s((dest), (dest_size), (n) - 1, __VA_ARGS__); \ + (dest)[(n) - 1] = '\0'; \ + } while (GRN_FALSE) #else /* WIN32 */ # define grn_snprintf(dest, dest_size, n, ...) \ snprintf((dest), (n), __VA_ARGS__) #endif /* WIN32 */ #ifdef WIN32 -# define grn_vsnprintf(dest, dest_size, format, args) \ - vsnprintf((dest), (dest_size) - 1, (format), (args)) +# define grn_vsnprintf(dest, dest_size, format, args) do { \ + vsnprintf((dest), (dest_size) - 1, (format), (args)); \ + (dest)[(dest_size) - 1] = '\0'; \ + } while (GRN_FALSE) #else /* WIN32 */ # define grn_vsnprintf(dest, dest_size, format, args) \ vsnprintf((dest), (dest_size), (format), (args)) Modified: lib/logger.c (+1 -3) =================================================================== --- lib/logger.c 2016-05-22 09:39:36 +0900 (8dbb408) +++ lib/logger.c 2016-05-22 16:04:52 +0900 (3135c14) @@ -387,15 +387,13 @@ grn_logger_putv(grn_ctx *ctx, grn_timeval2str(ctx, &tv, tbuf, TBUFSIZE); } if (current_logger.flags & GRN_LOG_MESSAGE) { - grn_vsnprintf(mbuf, MBUFSIZE - 1, fmt, ap); - mbuf[MBUFSIZE - 1] = '\0'; + grn_vsnprintf(mbuf, MBUFSIZE, fmt, ap); } else { mbuf[0] = '\0'; } if (current_logger.flags & GRN_LOG_LOCATION) { grn_snprintf(lbuf, LBUFSIZE, LBUFSIZE, "%d %s:%d %s()", getpid(), file, line, func); - lbuf[LBUFSIZE - 1] = '\0'; } else { lbuf[0] = '\0'; } -------------- next part -------------- HTML����������������������������... ダウンロード