[Coco] Fwd: MW-C Cross compiler bug - Solved
Gene Heskett
gheskett at wdtv.com
Sun Mar 9 17:01:44 EDT 2014
On Sunday 09 March 2014 17:00:09 Christopher R. Hawks did opine:
> On Sun, 09 Mar 2014 13:04:45 -0400
>
> Jamie Cho <silurian at icloud.com> wrote:
> > I tracked the error down to the space() function in cprep19.
> > Basically, it is no longer legal for strcpy() or memcpy() to be sent
> > overlapping arrays, but it is ok with memmove().
>
> In Unix/Posix it never was, that's what memmove() is for.
>
Are you saying that both of my copies (original and the "ANSI C" versions
of the K&R books are wrong?
> > The corrected version looks like:
> > int
> > space ( /* shrink spaces to one */
> >
> > int a, int b)
> >
> > {
> >
> > register char *cptr;
> > char *bptr;
> > size_t line_size;
> >
> > bptr = cptr = &line[b];
> >
> > while (*(++cptr) == ' ');
> >
> > if (bptr != cptr - 1)
> > {
> >
> > line_size = strlen(cptr);
> > memmove(bptr + 1, cptr, line_size);
> > a -= (cptr - bptr - 1);
> >
> > }
> >
> > return a;
> >
> > }
> >
> > Who is the maintainer of the compiler and where should updates be
> > posted?
> >
> > Best,
> > Jamie
> >
> > --
> > Coco mailing list
> > Coco at maltedmedia.com
> > http://five.pairlist.net/mailman/listinfo/coco
>
> Christopher R. Hawks
> HAWKSoft
Cheers, Gene
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page <http://geneslinuxbox.net:6309/gene>
More information about the Coco
mailing list