diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | intern.h | 14 | ||||
-rw-r--r-- | ruby.h | 22 |
3 files changed, 25 insertions, 15 deletions
@@ -1,3 +1,7 @@ +Tue Sep 13 20:24:37 2005 Tanaka Akira <akr@m17n.org> + + * ruby.h (PRINTF_ARGS): new macro for printf style argument checking. + Tue Sep 13 15:41:29 2005 Minero Aoki <aamine@loveruby.net> * lib/net/http.rb: wrote docuemntation of HTTPRequest/HTTPResponse @@ -153,11 +153,11 @@ RUBY_EXTERN int ruby_nerrs; VALUE rb_exc_new _((VALUE, const char*, long)); VALUE rb_exc_new2 _((VALUE, const char*)); VALUE rb_exc_new3 _((VALUE, VALUE)); -NORETURN(void rb_loaderror __((const char*, ...))); -NORETURN(void rb_name_error __((ID, const char*, ...))); +PRINTF_ARGS(NORETURN(void rb_loaderror __((const char*, ...))), 1, 2); +PRINTF_ARGS(NORETURN(void rb_name_error __((ID, const char*, ...))), 2, 3); NORETURN(void rb_invalid_str _((const char*, const char*))); -void rb_compile_error __((const char*, ...)); -void rb_compile_error_append __((const char*, ...)); +PRINTF_ARGS(void rb_compile_error __((const char*, ...)), 1, 2); +PRINTF_ARGS(void rb_compile_error_append __((const char*, ...)), 1, 2); NORETURN(void rb_load_fail _((const char*))); NORETURN(void rb_error_frozen _((const char*))); void rb_check_frozen _((VALUE)); @@ -468,11 +468,7 @@ void rb_trap_exec _((void)); const char *ruby_signal_name _((int)); /* sprintf.c */ VALUE rb_f_sprintf _((int, const VALUE*)); -VALUE rb_sprintf __((const char*, ...)) -#ifdef __GNUC__ - __attribute__((format(printf,1,2))) -#endif - ; +PRINTF_ARGS(VALUE rb_sprintf __((const char*, ...)), 1, 2); VALUE rb_vsprintf _((const char*, va_list)); VALUE rb_str_format _((int, const VALUE *, VALUE)); /* string.c */ @@ -31,6 +31,13 @@ extern "C" { # define NOINLINE(x) x #endif +#ifdef __GNUC__ +#define PRINTF_ARGS(decl, string_index, first_to_check) \ + decl __attribute__((format(printf, string_index, first_to_check))) +#else +#define PRINTF_ARGS(decl, string_index, first_to_check) decl +#endif + #include "defines.h" #ifdef HAVE_STDLIB_H @@ -539,17 +546,20 @@ VALUE rb_equal _((VALUE,VALUE)); RUBY_EXTERN VALUE ruby_verbose, ruby_debug; -NORETURN(void rb_raise __((VALUE, const char*, ...))); -NORETURN(void rb_fatal __((const char*, ...))); -NORETURN(void rb_bug __((const char*, ...))); +PRINTF_ARGS(NORETURN(void rb_raise __((VALUE, const char*, ...))), 2, 3); +PRINTF_ARGS(NORETURN(void rb_fatal __((const char*, ...))), 1, 2); +PRINTF_ARGS(NORETURN(void rb_bug __((const char*, ...))), 1, 2); NORETURN(void rb_sys_fail _((const char*))); NORETURN(void rb_iter_break _((void))); NORETURN(void rb_exit _((int))); NORETURN(void rb_notimplement _((void))); -void rb_warning __((const char*, ...)); /* reports if `-w' specified */ -void rb_sys_warning __((const char*, ...)); /* reports if `-w' specified */ -void rb_warn __((const char*, ...)); /* reports always */ +/* reports if `-w' specified */ +PRINTF_ARGS(void rb_warning __((const char*, ...)), 1, 2); +/* reports if `-w' specified */ +PRINTF_ARGS(void rb_sys_warning __((const char*, ...)), 1, 2); +/* reports always */ +PRINTF_ARGS(void rb_warn __((const char*, ...)), 1, 2); VALUE rb_each _((VALUE)); VALUE rb_yield _((VALUE)); |