From 984f056d6d36c462881680b864b946bccd9d42da Mon Sep 17 00:00:00 2001 From: Ciaran Anscomb Date: Thu, 23 Jan 2025 12:01:04 +0000 Subject: [PATCH 1/2] dc: fix off-by-one initialising symlst[] --- Applications/V7/cmd/dc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Applications/V7/cmd/dc.c b/Applications/V7/cmd/dc.c index 39208dcaa6..bc9ff53193 100644 --- a/Applications/V7/cmd/dc.c +++ b/Applications/V7/cmd/dc.c @@ -1123,7 +1123,7 @@ void init(int argc, char *argv[]) readptr = &readstk[0]; k = 0; sp = sptr = &symlst[0]; - while (sptr < &symlst[TBLSZ]) { + while (sptr < &symlst[TBLSZ-1]) { sptr->next = ++sp; sptr++; } From 9cafebe8d004da4c59b82f46e14f668927a9c535 Mon Sep 17 00:00:00 2001 From: Ciaran Anscomb Date: Thu, 23 Jan 2025 15:05:11 +0000 Subject: [PATCH 2/2] dc: explicitly declare signed char for number buffers Parts of the code depend on char being signed. Showed up for me trying square root, but probably affects other stuff too. --- Applications/V7/cmd/dc.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Applications/V7/cmd/dc.c b/Applications/V7/cmd/dc.c index bc9ff53193..f55675162d 100644 --- a/Applications/V7/cmd/dc.c +++ b/Applications/V7/cmd/dc.c @@ -45,10 +45,10 @@ #define errorrt(p) {printf(p); return NULL; } struct blk { - char *rd; - char *wt; - char *beg; - char *last; + signed char *rd; + signed char *wt; + signed char *beg; + signed char *last; }; struct sym { struct sym *next; @@ -145,8 +145,8 @@ void (*outdit) (struct blk *, int); int logo; int intlog10; int count; -char *pp; -char *dummy; +signed char *pp; +signed char *dummy; int main(int argc, char *argv[]) { @@ -1958,7 +1958,7 @@ struct blk *copy(struct blk *hptr, int size) { register struct blk *hdr; register unsigned sz; - register char *ptr; + register signed char *ptr; all++; nbytes += size; @@ -1985,7 +1985,7 @@ struct blk *copy(struct blk *hptr, int size) void sdump(char *s1, struct blk *hptr) { - char *p; + signed char *p; printf("%s %o rd %o wt %o beg %o last %o\n", s1, hptr, hptr->rd, hptr->wt, hptr->beg, hptr->last); p = hptr->beg; @@ -1996,7 +1996,7 @@ void sdump(char *s1, struct blk *hptr) void seekc(struct blk *hptr, int n) { - char *nn, *p; + signed char *nn, *p; nn = hptr->beg + n; if (nn > hptr->last) { @@ -2123,7 +2123,7 @@ void garbage(char *s) void redef(struct blk *p) { register int offset; - register char *newp; + register signed char *newp; if ((int) p->beg & 01) { printf("odd ptr %o hdr %o\n", p->beg, p);