[Coco] Fwd: MW-C Cross compiler bug - Solved

Christopher R. Hawks chawks at dls.net
Sun Mar 9 16:30:48 EDT 2014


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.

> 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
-- 
Actual newspaper headline: Cold Wave Linked to Temperatures



More information about the Coco mailing list