aboutsummaryrefslogtreecommitdiffstats
path: root/vsnprintf.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-04 03:51:33 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-04 03:51:33 +0000
commita9f3eb75de7c4041b273cc782585e1b7b20a6fa4 (patch)
treebc3e0feff04abf0f51714a7300755890986e5e78 /vsnprintf.c
parent95e83cb3f940cc1a8ab7681ad01f67aba77554a0 (diff)
downloadruby-a9f3eb75de7c4041b273cc782585e1b7b20a6fa4.tar.gz
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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vsnprintf.c')
-rw-r--r--vsnprintf.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/vsnprintf.c b/vsnprintf.c
index f8b5a8970b..36f6f25465 100644
--- a/vsnprintf.c
+++ b/vsnprintf.c
@@ -806,7 +806,21 @@ reswitch: switch (ch) {
#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);