[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
trim_pathname in general.c should use memmove rather than memcpy
From: |
Matthew Riley |
Subject: |
trim_pathname in general.c should use memmove rather than memcpy |
Date: |
Wed, 13 Mar 2013 14:17:56 -0700 |
...
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:
/home/mattdr$ echo $PROMPT_DIRTRIM
6
/home/mattdr$ echo $PS1
\w$
/home/mattdr$ cd alpha/beta/gamma/delta/epsilon/zeta/eta/theta/iota/
...eta/iotapsilon/zeta/eta/theta/iota$ pwd
/home/mattdr/alpha/beta/gamma/delta/epsilon/zeta/eta/theta/iota
Note the prompt includes two instances of "iota" but the path only includes
one.
- trim_pathname in general.c should use memmove rather than memcpy,
Matthew Riley <=