From: ceriel Date: Tue, 19 Mar 1991 11:14:39 +0000 (+0000) Subject: do not write in strings: they could reside in ROM X-Git-Tag: release-5-5~1173 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=2684a45cc5abe23e7a66e0b78cd4a3526bb49780;p=ack.git do not write in strings: they could reside in ROM --- 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;