[Coco] Os9 C cross compiler. Progress!

James Jones jejones3141 at gmail.com
Fri Nov 22 16:29:31 EST 2019


Good debugging. As Tormod says, memmove() is guaranteed to work even with
overlapping regions. I think that for the others, overlap results in
undefined behavior.

On Fri, Nov 22, 2019 at 12:11 AM Walter Zambotti <zambotti at iinet.net.au>
wrote:

> After much debugging I found what was causing a problem in ansifront.
>
>
>
> It turned out to be a logic assumption in coprep (c_prep19) that was
> passing
> on its problems.
>
>
>
> In the:
>
>
>
> int space(int a, int b)
>
>
>
> function.
>
>
>
> There was this line of code:
>
>
>
> strcpy(bptr + 1, cptr);
>
>
>
> where bptr and cptr are pointers within the same string. Bptr points to
> beginning of white space and cptr points to first non white character ther
> after.
>
>
>
> The line basically converts multiple spaces into one space.
>
>
>
> However as the both pointers are in the same string this implies
> overlapping
> copy areas.
>
>
>
> So this will only work if the strcpy function is guaranteed to copy from
> left to right.
>
>
>
> While this may be the case for strcpy on OS9 it appears not to be the case
> for Linux on Intel.
>
>
>
> I stepped over that line of code many times before I detected the problem.
>
>
>
> So several hours later 1 more bug down!
>
>
>
> Both coprep & ansifront now appear to be working. I'll keep you all posted.
>
>
>
> Walter
>
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
>


More information about the Coco mailing list