Skip to content

Commit 67d6a79

Browse files
authored
Merge pull request #158 from Interlisp/unwind-int-unsigned-ptr-confusion
Correct handling of return value of N_OP_unwind()
2 parents fc3908f + 12c5f32 commit 67d6a79

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

inc/inlineC.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -852,8 +852,7 @@ nextop2; \
852852

853853
#define UNWIND(n, m) \
854854
{ \
855-
if ((INT)(CSTKPTRL = (LispPTR *) \
856-
N_OP_unwind(CSTKPTR, TOPOFSTACK, n, m)) < 0) \
855+
if ((CSTKPTRL = N_OP_unwind(CSTKPTR, TOPOFSTACK, n, m)) == (LispPTR *)-1) \
857856
goto unwind_err; \
858857
POP; \
859858
nextop3; \

inc/unwinddefs.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#ifndef UNWINDDEFS_H
22
#define UNWINDDEFS_H 1
3-
UNSIGNED N_OP_unwind(register LispPTR *cstkptr, register LispPTR tos, int n, int keep);
3+
LispPTR *N_OP_unwind(register LispPTR *cstkptr, register LispPTR tos, int n, int keep);
44
#endif

src/unwind.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
#include "unwinddefs.h"
3030

31-
UNSIGNED N_OP_unwind(register LispPTR *cstkptr, register LispPTR tos, int n, int keep) {
31+
LispPTR *N_OP_unwind(register LispPTR *cstkptr, register LispPTR tos, int n, int keep) {
3232
register int num; /* number of UNBOUND slot */
3333
register LispPTR *endptr; /* unwind limit */
3434
register LispPTR *lastpvar; /* points PVar slot that is unbounded. */
@@ -64,7 +64,10 @@ UNSIGNED N_OP_unwind(register LispPTR *cstkptr, register LispPTR tos, int n, int
6464

6565
if (endptr > cstkptr) {
6666
CurrentStackPTR = (DLword *)cstkptr;
67-
ERROR_EXIT(tos);
67+
/* this would be ERROR_EXIT(tos); but for having to return a pointer */
68+
TopOfStack = tos;
69+
Error_Exit = 1;
70+
return (LispPTR *)(-1);
6871
}
6972
*cstkptr++ = tos;
7073

@@ -85,7 +88,7 @@ UNSIGNED N_OP_unwind(register LispPTR *cstkptr, register LispPTR tos, int n, int
8588
/* endptr = cstkptr */
8689

8790
if (keep) { *(cstkptr++) = tos; }
88-
return ((UNSIGNED)cstkptr);
91+
return (cstkptr);
8992

9093
} /* N_OP_unwind */
9194

0 commit comments

Comments
 (0)