summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-25 02:09:22 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-25 02:09:22 +0000
commitd9adb03dd902c1cf7e5fadc8320dccec0ef73139 (patch)
tree0ff85b8779d48f548f71c2c08e5ac7343778b59d /ext
parentaa281e75179caa27228a0051efb94d14f7c553e4 (diff)
* ext/curses/curses.c (Init_curses): use rb_define_const once for
Curses::VERSION. * ext/dbm/dbm.c (Init_dbm): ditto for DBM::VERSION. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/curses/curses.c16
-rw-r--r--ext/dbm/dbm.c34
2 files changed, 27 insertions, 23 deletions
diff --git a/ext/curses/curses.c b/ext/curses/curses.c
index 69dc09cf301..20f23d188b2 100644
--- a/ext/curses/curses.c
+++ b/ext/curses/curses.c
@@ -2768,20 +2768,22 @@ Init_curses(void)
rb_define_module_function(mCurses, "def_prog_mode", curses_def_prog_mode, 0);
rb_define_module_function(mCurses, "reset_prog_mode", curses_reset_prog_mode, 0);
+ {
+ VALUE version;
#if defined(HAVE_FUNC_CURSES_VERSION)
- /* ncurses and PDcurses */
- rb_define_const(mCurses, "VERSION", rb_str_new2(curses_version()));
+ /* ncurses and PDcurses */
+ version = rb_str_new2(curses_version());
#elif defined(HAVE_VAR_CURSES_VERSION)
- {
/* SVR4 curses has an undocumented and undeclared variable, curses_version.
* It contains a string, "SVR4". */
RUBY_EXTERN char *curses_version;
- rb_define_const(mCurses, "VERSION", rb_sprintf("curses (%s)", curses_version));
- }
+ version = rb_sprintf("curses (%s)", curses_version);
#else
- /* BSD curses, perhaps. NetBSD 5 still use it. */
- rb_define_const(mCurses, "VERSION", rb_str_new2("curses (unknown)"));
+ /* BSD curses, perhaps. NetBSD 5 still use it. */
+ version = rb_str_new2("curses (unknown)");
#endif
+ rb_define_const(mCurses, "VERSION", version);
+ }
/*
* Document-class: Curses::Window
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c
index f220d3e7c0a..e0640d96384 100644
--- a/ext/dbm/dbm.c
+++ b/ext/dbm/dbm.c
@@ -1085,36 +1085,38 @@ Init_dbm(void)
*/
rb_define_const(rb_cDBM, "NEWDB", INT2FIX(O_RDWR|O_CREAT|O_TRUNC|RUBY_DBM_RW_BIT));
+ {
+ VALUE version;
#if defined(_DBM_IOERR)
- rb_define_const(rb_cDBM, "VERSION", rb_str_new2("ndbm (4.3BSD)"));
+ version = rb_str_new2("ndbm (4.3BSD)");
#elif defined(RUBYDBM_GDBM_HEADER)
# if defined(HAVE_DECLARED_LIBVAR_GDBM_VERSION)
- /* since gdbm 1.9 */
- rb_define_const(rb_cDBM, "VERSION", rb_str_new2(gdbm_version));
+ /* since gdbm 1.9 */
+ version = rb_str_new2(gdbm_version);
# elif defined(HAVE_UNDECLARED_LIBVAR_GDBM_VERSION)
- /* ndbm.h doesn't declare gdbm_version until gdbm 1.8.3.
- * See extconf.rb for more information. */
- {
- RUBY_EXTERN char *gdbm_version;
- rb_define_const(rb_cDBM, "VERSION", rb_str_new2(gdbm_version));
- }
+ /* ndbm.h doesn't declare gdbm_version until gdbm 1.8.3.
+ * See extconf.rb for more information. */
+ RUBY_EXTERN char *gdbm_version;
+ version = rb_str_new2(gdbm_version);
# else
- rb_define_const(rb_cDBM, "VERSION", rb_str_new2("GDBM (unknown)"));
+ version = rb_str_new2("GDBM (unknown)");
# endif
#elif defined(RUBYDBM_DB_HEADER)
# if defined(HAVE_DB_VERSION)
- /* The version of the dbm library, if using Berkeley DB */
- rb_define_const(rb_cDBM, "VERSION", rb_str_new2(db_version(NULL, NULL, NULL)));
+ /* The version of the dbm library, if using Berkeley DB */
+ version = rb_str_new2(db_version(NULL, NULL, NULL));
# else
- rb_define_const(rb_cDBM, "VERSION", rb_str_new2("Berkeley DB (unknown)"));
+ version = rb_str_new2("Berkeley DB (unknown)");
# endif
#elif defined(_RELIC_H)
# if defined(HAVE_DPVERSION)
- rb_define_const(rb_cDBM, "VERSION", rb_sprintf("QDBM %s", dpversion));
+ version = rb_sprintf("QDBM %s", dpversion);
# else
- rb_define_const(rb_cDBM, "VERSION", rb_str_new2("QDBM (unknown)"));
+ version = rb_str_new2("QDBM (unknown)");
# endif
#else
- rb_define_const(rb_cDBM, "VERSION", rb_str_new2("ndbm (unknown)"));
+ version = rb_str_new2("ndbm (unknown)");
#endif
+ rb_define_const(rb_cDBM, "VERSION", version);
+ }
}