[Coco] Fwd: MW-C Cross compiler bug - Solved
Luis Antoniosi (CoCoDemus)
retrocanada76 at gmail.com
Sun Mar 9 17:09:13 EDT 2014
current memcpy and strcpy have restrict pointers. This means they do
not aliases each other.
void *memcpy(void * restrict s1, const void * restrict s2, size_t n);
void *memmove(void * s1, const void * s2, size_t n);
memove can copy backwards when needed.
On Sun, Mar 9, 2014 at 5:01 PM, Gene Heskett <gheskett at wdtv.com> wrote:
> 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>
>
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> http://five.pairlist.net/mailman/listinfo/coco
--
Long live the CoCo
More information about the Coco
mailing list