From 2684a45cc5abe23e7a66e0b78cd4a3526bb49780 Mon Sep 17 00:00:00 2001 From: ceriel Date: Tue, 19 Mar 1991 11:14:39 +0000 Subject: [PATCH] do not write in strings: they could reside in ROM --- lang/m2/libm2/catch.c | 3 +-- lang/pc/libpc/catch.c | 33 +++++++++++++++++---------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lang/m2/libm2/catch.c b/lang/m2/libm2/catch.c index cc2b59cde..7ee5451d6 100644 --- a/lang/m2/libm2/catch.c +++ b/lang/m2/libm2/catch.c @@ -59,7 +59,6 @@ catch(trapno) char *errmessage; char buf[20]; register char *p, *s; - char *q; while (ep->errno != trapno && ep->errmes != 0) ep++; if (p = ep->errmes) { @@ -68,8 +67,8 @@ catch(trapno) } else { int i = trapno; + static char q[] = "error number xxxxxxxxxxxxx"; - q = "error number xxxxxxxxxxxxx"; p = &q[13]; s = buf; if (i < 0) { diff --git a/lang/pc/libpc/catch.c b/lang/pc/libpc/catch.c index 616a18d59..1526e6267 100644 --- a/lang/pc/libpc/catch.c +++ b/lang/pc/libpc/catch.c @@ -20,9 +20,6 @@ #include #include -#define MESLEN 30 -#define PATHLEN 100 - /* to make it easier to patch ... */ extern struct file *_curfil; @@ -97,8 +94,8 @@ _catch(erno) unsigned erno; { char buf[20]; unsigned i; int j = erno; - char *pp[10]; - char mes[MESLEN]; + char *pp[11]; + char xbuf[100]; qq = pp; if (p = FILN) @@ -107,14 +104,19 @@ _catch(erno) unsigned erno; { *qq++ = _pargv[0]; while (ep->errno != erno && ep->errmes != 0) ep++; - p = &("xxxxx: "[5]); + p = buf; + s = xbuf; if (i = LINO) { *qq++ = ", "; do - *--p = i % 10 + '0'; + *p++ = i % 10 + '0'; while (i /= 10); + while (p > buf) *s++ = *--p; } - *qq++ = p; + *s++ = ':'; + *s++ = ' '; + *s++ = '\0'; + *qq++ = xbuf; if ((erno & ~037) == 0140 && (_curfil->flags&0377)==MAGIC) { /* file error */ *qq++ = "file "; @@ -123,19 +125,18 @@ _catch(erno) unsigned erno; { } if (ep->errmes) *qq++ = ep->errmes; else { - q = "error number xxxxxxxxxxxxx"; - p = &q[13]; - s = buf; + *qq++ = "error number "; + *qq++ = s; + p = buf; if (j < 0) { j = -j; - *p++ = '-'; + *s++ = '-'; } do - *s++ = j % 10 + '0'; + *p++ = j % 10 + '0'; while (j /= 10); - while (s > buf) *p++ = *--s; - *p = 0; - *qq++ = q; + while (p > buf) *s++ = *--p; + *s = 0; } *qq++ = "\n"; *qq = 0;