ruby-changes:36181
From: nobu <ko1@a...>
Date: Tue, 4 Nov 2014 12:51:46 +0900 (JST)
Subject: [ruby-changes:36181] nobu:r48262 (trunk): ruby.h: add mark to PRIsVALUE
nobu 2014-11-04 12:51:33 +0900 (Tue, 04 Nov 2014) New Revision: 48262 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48262 Log: ruby.h: add mark to PRIsVALUE * include/ruby/ruby.h (PRIsVALUE), vsnprintf.c (BSD_vfprintf): add RUBY_PRI_VALUE_MARK to reduce danger of accidental conflict with plain "%i". binary incompatible with extension libraries using PRIsVALUE and built for 2.1 and earlier. [EXPERIMENTAL] Modified files: trunk/ChangeLog trunk/include/ruby/ruby.h trunk/sprintf.c trunk/vsnprintf.c Index: include/ruby/ruby.h =================================================================== --- include/ruby/ruby.h (revision 48261) +++ include/ruby/ruby.h (revision 48262) @@ -123,20 +123,21 @@ typedef char ruby_check_sizeof_voidp[SIZ https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L123 #define PRI_64_PREFIX PRI_LL_PREFIX #endif +#define RUBY_PRI_VALUE_MARK "\v" #if defined PRIdPTR && !defined PRI_VALUE_PREFIX #define PRIdVALUE PRIdPTR #define PRIoVALUE PRIoPTR #define PRIuVALUE PRIuPTR #define PRIxVALUE PRIxPTR #define PRIXVALUE PRIXPTR -#define PRIsVALUE PRIiPTR +#define PRIsVALUE PRIiPTR""RUBY_PRI_VALUE_MARK #else #define PRIdVALUE PRI_VALUE_PREFIX"d" #define PRIoVALUE PRI_VALUE_PREFIX"o" #define PRIuVALUE PRI_VALUE_PREFIX"u" #define PRIxVALUE PRI_VALUE_PREFIX"x" #define PRIXVALUE PRI_VALUE_PREFIX"X" -#define PRIsVALUE PRI_VALUE_PREFIX"i" +#define PRIsVALUE PRI_VALUE_PREFIX"i"RUBY_PRI_VALUE_MARK #endif #ifndef PRI_VALUE_PREFIX # define PRI_VALUE_PREFIX "" Index: ChangeLog =================================================================== --- ChangeLog (revision 48261) +++ ChangeLog (revision 48262) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Nov 4 12:51:31 2014 Nobuyoshi Nakada <nobu@r...> + + * include/ruby/ruby.h (PRIsVALUE), vsnprintf.c (BSD_vfprintf): add + RUBY_PRI_VALUE_MARK to reduce danger of accidental conflict with + plain "%i". binary incompatible with extension libraries using + PRIsVALUE and built for 2.1 and earlier. [EXPERIMENTAL] + Tue Nov 4 12:33:44 2014 SHIBATA Hiroshi <shibata.hiroshi@g...> * object.c: fix document of Kernel#String by @suzukaze Index: vsnprintf.c =================================================================== --- vsnprintf.c (revision 48261) +++ vsnprintf.c (revision 48262) @@ -806,7 +806,21 @@ reswitch: switch (ch) { https://github.com/ruby/ruby/blob/trunk/vsnprintf.c#L806 #else # define INTPTR_FLAG 0 #endif - if (fp->vextra && (flags & INTPTR_MASK) == INTPTR_FLAG) { +#ifdef PRI_EXTRA_MARK +# define PRI_EXTRA_MARK_LEN (sizeof(PRI_EXTRA_MARK)-1) +# define IS_PRI_EXTRA_MARK(s) \ + (PRI_EXTRA_MARK_LEN < 1 || \ + (*(s) == PRI_EXTRA_MARK[0] && \ + (PRI_EXTRA_MARK_LEN == 1 || \ + strncmp((s)+1, PRI_EXTRA_MARK+1, \ + PRI_EXTRA_MARK_LEN-1) == 0))) +#else +# define PRI_EXTRA_MARK_LEN 0 +# define IS_PRI_EXTRA_MARK(s) 1 +#endif + if (fp->vextra && (flags & INTPTR_MASK) == INTPTR_FLAG && + IS_PRI_EXTRA_MARK(fmt)) { + fmt += PRI_EXTRA_MARK_LEN; FLUSH(); #if defined _HAVE_SANE_QUAD_ && SIZEOF_VOIDP == SIZEOF_LONG_LONG uqval = va_arg(ap, u_quad_t); Index: sprintf.c =================================================================== --- sprintf.c (revision 48261) +++ sprintf.c (revision 48262) @@ -1253,6 +1253,9 @@ fmt_setup(char *buf, size_t size, int c, https://github.com/ruby/ruby/blob/trunk/sprintf.c#L1253 #define FLOATING_POINT 1 #define BSD__dtoa ruby_dtoa #define BSD__hdtoa ruby_hdtoa +#ifdef RUBY_PRI_VALUE_MARK +# define PRI_EXTRA_MARK RUBY_PRI_VALUE_MARK +#endif #include "vsnprintf.c" typedef struct { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/