Skip to content

Commit

Permalink
apply mkxp-z patches
Browse files Browse the repository at this point in the history
Several changes by either me or Aeodyn.
Some make Ruby more like older versions, and others
are so that it works correctly on Windows.
  • Loading branch information
Struma committed Jan 13, 2022
1 parent fb4df44 commit a2d396e
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 7 deletions.
3 changes: 3 additions & 0 deletions class.c
Original file line number Diff line number Diff line change
Expand Up @@ -847,13 +847,16 @@ rb_define_class(const char *name, VALUE super)
name, rb_obj_class(klass));
}
if (rb_class_real(RCLASS_SUPER(klass)) != super) {
// edited for mkxp-z compatibility
goto override_class;
rb_raise(rb_eTypeError, "superclass mismatch for class %s", name);
}

/* Class may have been defined in Ruby and not pin-rooted */
rb_vm_add_root_module(klass);
return klass;
}
override_class:
if (!super) {
rb_raise(rb_eArgError, "no super class for `%s'", name);
}
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ main()
AC_CHECK_FUNCS(cygwin_conv_path)
AC_LIBOBJ([langinfo])
],
[mingw*], [ LIBS="-lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi -lbcrypt $LIBS"
[mingw*], [ LIBS="-lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi -lbcrypt -Wl,-Bstatic -lgcc -lpthread -lz -lffi -Wl,-Bdynamic $LIBS"
ac_cv_header_pwd_h=no
ac_cv_header_utime_h=no
ac_cv_header_sys_ioctl_h=no
Expand Down
2 changes: 1 addition & 1 deletion include/ruby/win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ typedef int clockid_t;
#define getpid() rb_w32_getpid()
#define getppid() rb_w32_getppid()
#define sleep(x) rb_w32_Sleep((x)*1000)
#define Sleep(msec) (void)rb_w32_Sleep(msec)
#define RB_Sleep(msec) (void)rb_w32_Sleep(msec)

#undef execv
#define execv(path,argv) rb_w32_uaspawn(P_OVERLAY,path,argv)
Expand Down
2 changes: 2 additions & 0 deletions sprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -931,11 +931,13 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
rb_str_tmp_frozen_release(orig, fmt);
/* XXX - We cannot validate the number of arguments if (digit)$ style used.
*/
#if 0
if (posarg >= 0 && nextarg < argc) {
const char *mesg = "too many arguments for format string";
if (RTEST(ruby_debug)) rb_raise(rb_eArgError, "%s", mesg);
if (RTEST(ruby_verbose)) rb_warn("%s", mesg);
}
#endif
rb_str_resize(result, blen);

return result;
Expand Down
2 changes: 1 addition & 1 deletion thread_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#define TIME_QUANTUM_USEC (10 * 1000)
#define RB_CONDATTR_CLOCK_MONOTONIC 1 /* no effect */

#undef Sleep
//#undef Sleep

#define native_thread_yield() Sleep(0)
#define unregister_ubf_list(th)
Expand Down
2 changes: 1 addition & 1 deletion vm_eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ rb_method_call_status(rb_execution_context_t *ec, const rb_callable_method_entry
rb_method_visibility_t visi = METHOD_ENTRY_VISI(me);

/* receiver specified form for private method */
if (UNLIKELY(visi != METHOD_VISI_PUBLIC)) {
if (0) { //UNLIKELY(visi != METHOD_VISI_PUBLIC)) {
if (me->def->original_id == idMethodMissing) {
return MISSING_NONE;
}
Expand Down
5 changes: 4 additions & 1 deletion vm_insnhelper.c
Original file line number Diff line number Diff line change
Expand Up @@ -3722,9 +3722,11 @@ vm_call_method(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_ca
if (vm_cc_cme(cc) != NULL) {
switch (METHOD_ENTRY_VISI(vm_cc_cme(cc))) {
case METHOD_VISI_PUBLIC: /* likely */
call_anyway:
return vm_call_method_each_type(ec, cfp, calling);

case METHOD_VISI_PRIVATE:
goto call_anyway;
if (!(vm_ci_flag(ci) & VM_CALL_FCALL)) {
enum method_missing_reason stat = MISSING_PRIVATE;
if (vm_ci_flag(ci) & VM_CALL_VCALL) stat |= MISSING_VCALL;
Expand All @@ -3736,6 +3738,7 @@ vm_call_method(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_ca
return vm_call_method_each_type(ec, cfp, calling);

case METHOD_VISI_PROTECTED:
goto call_anyway;
if (!(vm_ci_flag(ci) & VM_CALL_OPT_SEND)) {
if (!rb_obj_is_kind_of(cfp->self, vm_cc_cme(cc)->defined_class)) {
vm_cc_method_missing_reason_set(cc, MISSING_PROTECTED);
Expand Down Expand Up @@ -4476,7 +4479,7 @@ vm_check_if_class(ID id, rb_num_t flags, VALUE super, VALUE klass)
else if (VM_DEFINECLASS_HAS_SUPERCLASS_P(flags)) {
VALUE tmp = rb_class_real(RCLASS_SUPER(klass));

if (tmp != super) {
if (0) { //tmp != super) {
rb_raise(rb_eTypeError,
"superclass mismatch for class %"PRIsVALUE"",
rb_id2str(id));
Expand Down
4 changes: 2 additions & 2 deletions win32/win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -1375,7 +1375,7 @@ rb_w32_start_process(const char *abspath, char *const *argv, int out_fd)
return NULL;
}

if (!CreateChild(&child, wcmd, wprog, NULL, outHandle, outHandle, 0)) {
if (!CreateChild(&child, wcmd, wprog, NULL, outHandle, outHandle, CREATE_NO_WINDOW)) {
return NULL;
}

Expand Down Expand Up @@ -3187,7 +3187,7 @@ compare(const struct timeval *t1, const struct timeval *t2)
return 0;
}

#undef Sleep
//#undef Sleep

int rb_w32_check_interrupt(void *); /* @internal */

Expand Down

0 comments on commit a2d396e

Please sign in to comment.