aboutsummaryrefslogtreecommitdiffstats
path: root/src/lread.c
diff options
context:
space:
mode:
authorPaul Eggert2012-07-10 14:48:34 -0700
committerPaul Eggert2012-07-10 14:48:34 -0700
commite99a530f8cdca3ccd9e739cd092ed9865d12fe89 (patch)
treec2bef9f80ff9910be17757a83f61caed02146d0a /src/lread.c
parentc59592b32f5b5808c12720bfd37ea73b473fa1db (diff)
downloademacs-e99a530f8cdca3ccd9e739cd092ed9865d12fe89.tar.gz
emacs-e99a530f8cdca3ccd9e739cd092ed9865d12fe89.zip
Simplify by avoiding confusing use of strncpy etc.
Diffstat (limited to 'src/lread.c')
-rw-r--r--src/lread.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/src/lread.c b/src/lread.c
index bd85e44093e..640414b3e91 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1495,26 +1495,14 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto
1495 1495
1496 /* Concatenate path element/specified name with the suffix. 1496 /* Concatenate path element/specified name with the suffix.
1497 If the directory starts with /:, remove that. */ 1497 If the directory starts with /:, remove that. */
1498 if (SCHARS (filename) > 2 1498 int prefixlen = ((SCHARS (filename) > 2
1499 && SREF (filename, 0) == '/' 1499 && SREF (filename, 0) == '/'
1500 && SREF (filename, 1) == ':') 1500 && SREF (filename, 1) == ':')
1501 { 1501 ? 2 : 0);
1502 fnlen = SBYTES (filename) - 2; 1502 fnlen = SBYTES (filename) - prefixlen;
1503 strncpy (fn, SSDATA (filename) + 2, fnlen); 1503 memcpy (fn, SDATA (filename) + prefixlen, fnlen);
1504 fn[fnlen] = '\0'; 1504 memcpy (fn + fnlen, SDATA (XCAR (tail)), lsuffix + 1);
1505 } 1505 fnlen += lsuffix;
1506 else
1507 {
1508 fnlen = SBYTES (filename);
1509 strncpy (fn, SSDATA (filename), fnlen);
1510 fn[fnlen] = '\0';
1511 }
1512
1513 if (lsuffix != 0) /* Bug happens on CCI if lsuffix is 0. */
1514 {
1515 strncat (fn, SSDATA (XCAR (tail)), lsuffix);
1516 fnlen += lsuffix;
1517 }
1518 /* Check that the file exists and is not a directory. */ 1506 /* Check that the file exists and is not a directory. */
1519 /* We used to only check for handlers on non-absolute file names: 1507 /* We used to only check for handlers on non-absolute file names:
1520 if (absolute) 1508 if (absolute)