From d0cd2f2df02ed02955854eee0cea680f21aecc2c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net>
Date: Sun, 8 Nov 1998 23:23:18 -0800
Subject: [PATCH] fixed a bug in parent locating

Rev: src/interpret.c:1.97
Rev: src/program.c:1.103
Rev: src/testsuite.in:1.133
---
 src/interpret.c  | 19 +++++++++++++++++--
 src/program.c    |  4 +++-
 src/testsuite.in | 19 ++++++++++++++++++-
 3 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/src/interpret.c b/src/interpret.c
index c03120ba4e..496cd4252f 100644
--- a/src/interpret.c
+++ b/src/interpret.c
@@ -4,7 +4,7 @@
 ||| See the files COPYING and DISCLAIMER for more information.
 \*/
 #include "global.h"
-RCSID("$Id: interpret.c,v 1.96 1998/10/16 15:29:39 grubba Exp $");
+RCSID("$Id: interpret.c,v 1.97 1998/11/09 07:23:15 hubbe Exp $");
 #include "interpret.h"
 #include "object.h"
 #include "program.h"
@@ -390,7 +390,7 @@ void print_return_value(void)
 struct callback_list evaluator_callbacks;
 
 #ifdef DEBUG
-static char trace_buffer[100];
+static char trace_buffer[200];
 #define GET_ARG() (backlog[backlogp].arg=(\
   instr=prefix,\
   prefix=0,\
@@ -674,10 +674,25 @@ static int eval_instruction(unsigned char *pc)
 	{
 	  if(inherit->parent_offset)
 	  {
+#ifdef DEBUG
+	    if(t_flag>4)
+	    {
+	      sprintf(trace_buffer,"-   Following o->parent (accumulator+=%d)\n",inherit->parent_offset-1);
+	      write_to_stderr(trace_buffer,strlen(trace_buffer));
+	    }
+#endif
+
 	    i=o->parent_identifier;
 	    o=o->parent;
 	    accumulator+=inherit->parent_offset-1;
 	  }else{
+#ifdef DEBUG
+	    if(t_flag>4)
+	    {
+	      sprintf(trace_buffer,"-   Following inherit->parent (accumulator+=%d)\n",inherit->parent_offset-1);
+	      write_to_stderr(trace_buffer,strlen(trace_buffer));
+	    }
+#endif
 	    i=inherit->parent_identifier;
 	    o=inherit->parent;
 	  }
diff --git a/src/program.c b/src/program.c
index 9149516c93..2c680814c7 100644
--- a/src/program.c
+++ b/src/program.c
@@ -4,7 +4,7 @@
 ||| See the files COPYING and DISCLAIMER for more information.
 \*/
 #include "global.h"
-RCSID("$Id: program.c,v 1.102 1998/11/06 03:46:27 hubbe Exp $");
+RCSID("$Id: program.c,v 1.103 1998/11/09 07:23:16 hubbe Exp $");
 #include "program.h"
 #include "object.h"
 #include "dynamic_buffer.h"
@@ -1217,6 +1217,8 @@ void low_inherit(struct program *p,
 	inherit.parent=par;
 	inherit.parent_identifier=pid;
 	inherit.parent_offset=0;
+      }else{
+	inherit.parent_offset+=parent_offset;
       }
     }
     if(inherit.parent) add_ref(inherit.parent);
diff --git a/src/testsuite.in b/src/testsuite.in
index d78107b6a7..00f1c733db 100644
--- a/src/testsuite.in
+++ b/src/testsuite.in
@@ -1,4 +1,4 @@
-stest_true([["$Id: testsuite.in,v 1.132 1998/11/07 07:40:11 hubbe Exp $"]])
+stest_true([["$Id: testsuite.in,v 1.133 1998/11/09 07:23:18 hubbe Exp $"]])
 cond([[all_constants()->_verify_internals]],
 [[
   test_do(_verify_internals())
@@ -25,6 +25,23 @@ bar"]],[["foo\nbar"]])
 test_true([[stringp(#string "Makefile")]])
 test_any([[class Bar { array(int) foo = ({}); }; class Foo { inherit Bar; array(int) foo = ({1}); }; return sizeof(Foo()->foo);]],1)
 
+test_any([[return class Z {
+string bonk() { return "oiff"; }
+
+class A
+{
+  string bonk_me() { return bonk(); }
+}
+
+class B { inherit A; }
+
+class C
+{
+  string oiff() { return "bonk"; }
+  class D { inherit B; }
+}
+}()->C()->D()->bonk_me()]],"oiff")
+
 test_false([[object_variablep(class X { int y; int z() { return 1; }}(),"foo")]])
 test_false([[object_variablep(class X { int y; int z() { return 1; }}(),"z")]])
 test_true([[object_variablep(class X { int y; int z() { return 1; }}(),"y")]])
-- 
GitLab