summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
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 69dc09cf30..20f23d188b 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 f220d3e7c0..e0640d9638 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);
+ }
}