Skip to content

Commit 25c5381

Browse files
committed
Deprecate names under Struct
1 parent d8f1dd8 commit 25c5381

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

ext/etc/etc.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ char *getlogin();
5454

5555
#define RUBY_ETC_VERSION "1.1.0"
5656

57+
#ifdef HAVE_RB_DEPRECATE_CONSTANT
58+
void rb_deprecate_constant(VALUE mod, const char *name);
59+
#else
60+
# define rb_deprecate_constant(mod,name) ((void)(mod),(void)(name))
61+
#endif
62+
5763
#include "constdefs.h"
5864

5965
/* call-seq:
@@ -1165,6 +1171,7 @@ Init_etc(void)
11651171
rb_define_const(mEtc, "Passwd", sPasswd);
11661172
#endif
11671173
rb_define_const(rb_cStruct, "Passwd", sPasswd); /* deprecated name */
1174+
rb_deprecate_constant(rb_cStruct, "Passwd");
11681175
rb_extend_object(sPasswd, rb_mEnumerable);
11691176
rb_define_singleton_method(sPasswd, "each", etc_each_passwd, 0);
11701177

@@ -1200,6 +1207,7 @@ Init_etc(void)
12001207
rb_define_const(mEtc, "Group", sGroup);
12011208
#endif
12021209
rb_define_const(rb_cStruct, "Group", sGroup); /* deprecated name */
1210+
rb_deprecate_constant(rb_cStruct, "Group");
12031211
rb_extend_object(sGroup, rb_mEnumerable);
12041212
rb_define_singleton_method(sGroup, "each", etc_each_group, 0);
12051213
#endif

ext/etc/extconf.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
%x[#{RbConfig.ruby} #{srcdir}/mkconstants.rb -o #{srcdir}/constdefs.h]
4848
end
4949

50+
decl = [
51+
"void rb_deprecate_constant(VALUE, const char *);",
52+
]
53+
have_func('rb_deprecate_constant(Qnil, "None")', [decl])
54+
5055
$distcleanfiles << "constdefs.h"
5156

5257
create_makefile("etc")

0 commit comments

Comments
 (0)