[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: trim_pathname in general.c should use memmove rather than memcpy
From: |
Chet Ramey |
Subject: |
Re: trim_pathname in general.c should use memmove rather than memcpy |
Date: |
Thu, 14 Mar 2013 10:34:47 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130307 Thunderbird/17.0.4 |
On 3/13/13 5:17 PM, Matthew Riley wrote:
> ...
> nlen = nend - ntail;
> memcpy (nbeg, ntail, nlen);
> nbeg[nlen] = '\0';
>
> return name;
> ...
>
> [nbeg, nbeg+nlen) and [ntail, ntail+nlen) can overlap, so this code should
> use memmove. I'm pretty sure this explains why sometimes using
> PROMPT_DIRTRIM will give me a prompt with the last few components smeared
> over the rest of the string:
Good catch. Thanks for the report.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/