summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog19
-rw-r--r--configure.in5
-rw-r--r--include/ruby/missing.h16
-rw-r--r--include/ruby/ruby.h8
-rw-r--r--sprintf.c3
-rw-r--r--vsnprintf.c (renamed from missing/vsnprintf.c)29
-rwxr-xr-xwin32/mkexports.rb4
7 files changed, 33 insertions, 51 deletions
diff --git a/ChangeLog b/ChangeLog
index 1c35bfe6d7d..64588f6b06a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+Sun Apr 4 10:04:28 2010 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * include/ruby/ruby.h: replace snprintf and vsnprintf by
+ ruby_snprintf and ruby_vsnprintf. [ruby-dev:40909]
+
+ * configure.in: don't check snprintf(3) and vsnprintf(3).
+
+ * include/ruby/missing.h: don't delare snprintf and vsnprintf.
+
+ * include/ruby/ruby.h: include stdarg.h.
+
+ * sprintf.c: include vsnprintf.c
+
+ * vsnprintf.c: renamed from missing/vsnprintf.c.
+
+ * vsnprintf.c: remove useless ifdefs.
+
+ * win32/mkexports.rb: use ruby_snprintf and ruby_vsnprintf.
+
Sun Apr 4 09:44:01 2010 Tanaka Akira <akr@fsij.org>
* time.c (lt): call <=> instead of <.
diff --git a/configure.in b/configure.in
index d195f7521a6..5047e9e054e 100644
--- a/configure.in
+++ b/configure.in
@@ -888,8 +888,6 @@ main()
ac_cv_func_times=yes
ac_cv_func_waitpid=yes
ac_cv_func_fsync=yes
- ac_cv_func_snprintf=no
- ac_cv_func_vsnprintf=no
ac_cv_func_seekdir=yes
ac_cv_func_telldir=yes
ac_cv_func_isinf=yes
@@ -1116,7 +1114,6 @@ main()
rb_cv_broken_glibc_ia64_erfc=no)])
AS_CASE([$rb_cv_broken_glibc_ia64_erfc],[yes],[ac_cv_func_erf=no])
-AS_CASE(["$target_os"],[mingw*],[],[AC_REPLACE_FUNCS(vsnprintf)])
AC_REPLACE_FUNCS(dup2 memmove strerror\
strchr strstr crypt flock\
isnan finite isinf hypot acosh erf tgamma lgamma_r cbrt signbit \
@@ -1128,7 +1125,7 @@ AC_CHECK_FUNCS(fmod killpg wait4 waitpid fork spawnv syscall chroot getcwd eacce
setrgid setegid setregid setresgid issetugid pause lchown lchmod\
getpgrp setpgrp getpgid setpgid initgroups getgroups setgroups\
getpriority getrlimit setrlimit sysconf \
- dlopen sigprocmask sigaction sigsetjmp _setjmp _longjmp snprintf\
+ dlopen sigprocmask sigaction sigsetjmp _setjmp _longjmp\
setsid telldir seekdir fchmod cosh sinh tanh log2 round\
setuid setgid daemon select_large_fdset setenv unsetenv\
mktime timegm gmtime_r clock_gettime gettimeofday\
diff --git a/include/ruby/missing.h b/include/ruby/missing.h
index 4a900326323..e4ac07018fb 100644
--- a/include/ruby/missing.h
+++ b/include/ruby/missing.h
@@ -151,22 +151,6 @@ RUBY_EXTERN long strtol(const char *, char **, int);
#endif
*/
-#if defined HAVE_VSNPRINTF || defined HAVE_SNPRINTF
-# include <stdarg.h>
-#endif
-#ifndef HAVE_SNPRINTF
-RUBY_EXTERN int snprintf(char *, size_t n, char const *, ...);
-#endif
-#ifndef HAVE_VSNPRINTF
-# if _MSC_VER >= 1300
-# pragma warning(disable: 4273)
-# endif
-RUBY_EXTERN int vsnprintf(char *, size_t n, char const *, va_list);
-# if _MSC_VER >= 1300
-# pragma warning(default: 4273)
-# endif
-#endif
-
#ifndef HAVE_STRLCPY
RUBY_EXTERN size_t strlcpy(char *, const char*, size_t);
#endif
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index 5c00c8d1552..20f45aee4e2 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -67,6 +67,7 @@ extern "C" {
# include <inttypes.h>
#endif
+#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
@@ -1403,6 +1404,13 @@ unsigned long ruby_strtoul(const char *str, char **endptr, int base);
#define InitVM(ext) {void InitVM_##ext(void);InitVM_##ext();}
+int ruby_snprintf(char *str, size_t n, char const *fmt, ...);
+int ruby_vsnprintf(char *str, size_t n, char const *fmt, va_list ap);
+#undef snprintf
+#undef vsnprintf
+#define snprintf ruby_snprintf
+#define vsnprintf ruby_vsnprintf
+
#if defined(__cplusplus)
#if 0
{ /* satisfy cc-mode */
diff --git a/sprintf.c b/sprintf.c
index e26b833598d..1fa49e734ce 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -1113,10 +1113,9 @@ fmt_setup(char *buf, size_t size, int c, int flags, int width, int prec)
# define u_quad_t unsigned LONG_LONG
# endif
#endif
-#undef snprintf
#define FLOATING_POINT 1
#define BSD__dtoa ruby_dtoa
-#include "missing/vsnprintf.c"
+#include "vsnprintf.c"
static int
ruby__sfvwrite(register rb_printf_buffer *fp, register struct __suio *uio)
diff --git a/missing/vsnprintf.c b/vsnprintf.c
index acb09c9454d..6385aa1aa72 100644
--- a/missing/vsnprintf.c
+++ b/vsnprintf.c
@@ -230,7 +230,6 @@ struct __suio {
size_t uio_resid;
};
-#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_SNPRINTF)
/*
* Write some memory regions. Return zero on success, EOF on error.
*
@@ -305,7 +304,6 @@ static int BSD__sfvwrite(fp, uio)
}
return (0);
}
-#endif
/*
* Actual printf innards.
@@ -1219,13 +1217,8 @@ exponent(p0, exp, fmtch)
}
#endif /* FLOATING_POINT */
-#ifndef HAVE_VSNPRINTF
int
-vsnprintf(str, n, fmt, ap)
- char *str;
- size_t n;
- const char *fmt;
- _BSD_VA_LIST_ ap;
+ruby_vsnprintf(char *str, size_t n, const char *fmt, va_list ap)
{
int ret;
FILE f;
@@ -1240,22 +1233,9 @@ vsnprintf(str, n, fmt, ap)
*f._p = 0;
return (ret);
}
-#endif
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)snprintf.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#ifndef HAVE_SNPRINTF
int
-#if defined(HAVE_STDARG_PROTOTYPES)
-snprintf(char *str, size_t n, char const *fmt, ...)
-#else
-snprintf(str, n, fmt, va_alist)
-char *str, *fmt;
-size_t n;
-va_dcl
-#endif
+ruby_snprintf(char *str, size_t n, char const *fmt, ...)
{
int ret;
va_list ap;
@@ -1264,11 +1244,7 @@ va_dcl
if ((int)n < 1)
return (EOF);
-#if defined(HAVE_STDARG_PROTOTYPES)
va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
f._flags = __SWR | __SSTR;
f._bf._base = f._p = (unsigned char *)str;
f._bf._size = f._w = n - 1;
@@ -1278,4 +1254,3 @@ va_dcl
va_end(ap);
return (ret);
}
-#endif
diff --git a/win32/mkexports.rb b/win32/mkexports.rb
index 951429e35ac..2fac64bea30 100755
--- a/win32/mkexports.rb
+++ b/win32/mkexports.rb
@@ -51,8 +51,8 @@ class Exports
end
end
syms["NtInitialize"] ||= "ruby_sysinit" if syms["ruby_sysinit"]
- syms["rb_w32_vsnprintf"] ||= "vsnprintf"
- syms["rb_w32_snprintf"] ||= "snprintf"
+ syms["rb_w32_vsnprintf"] ||= "ruby_vsnprintf"
+ syms["rb_w32_snprintf"] ||= "ruby_snprintf"
@syms = syms
end