summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-07-05 12:12:47 +0200
committerNicholas Clark <nick@ccl4.org>2011-07-06 10:28:36 +0200
commit8304a6c43fb2482cbeadcb208b8f2e87c4a94726 (patch)
tree960754a4ede843f85f4da066e65b3114b45c264b
parent0a044a7cc96a996b26b8d31caa93c9627fa49e9e (diff)
downloadperl-8304a6c43fb2482cbeadcb208b8f2e87c4a94726.tar.gz
In Cwd.xs, tidy the conditional code related to symlinks.
Move the variable symlink inside the conditionally compiled code, to avoid on platforms which don't have symlinks about an unused variable. Move the pre-processor directives back to column zero - they were indented as part of the upgrade to PathTools 3.26_01 in c7304ea2604337d2. Correct the indentation of some lines [always just a closing '}'], which was making the code harder to follow. All these lines seem to have been left unaltered by c7304ea2604337d2, when code surrounding them changed.
-rw-r--r--dist/Cwd/Cwd.xs17
1 files changed, 9 insertions, 8 deletions
diff --git a/dist/Cwd/Cwd.xs b/dist/Cwd/Cwd.xs
index 7263c09868..d55c318073 100644
--- a/dist/Cwd/Cwd.xs
+++ b/dist/Cwd/Cwd.xs
@@ -71,7 +71,7 @@ bsd_realpath(const char *path, char resolved[MAXPATHLEN])
size_t left_len, resolved_len;
unsigned symlinks;
int serrno;
- char left[MAXPATHLEN], next_token[MAXPATHLEN], symlink[MAXPATHLEN];
+ char left[MAXPATHLEN], next_token[MAXPATHLEN];
serrno = errno;
symlinks = 0;
@@ -150,7 +150,7 @@ bsd_realpath(const char *path, char resolved[MAXPATHLEN])
errno = ENAMETOOLONG;
return (NULL);
}
- #if defined(HAS_LSTAT) && defined(HAS_READLINK) && defined(HAS_SYMLINK)
+#if defined(HAS_LSTAT) && defined(HAS_READLINK) && defined(HAS_SYMLINK)
{
struct stat sb;
if (lstat(resolved, &sb) != 0) {
@@ -162,6 +162,7 @@ bsd_realpath(const char *path, char resolved[MAXPATHLEN])
}
if (S_ISLNK(sb.st_mode)) {
int slen;
+ char symlink[MAXPATHLEN];
if (symlinks++ > MAXSYMLINKS) {
errno = ELOOP;
@@ -190,22 +191,22 @@ bsd_realpath(const char *path, char resolved[MAXPATHLEN])
if (p != NULL) {
if (symlink[slen - 1] != '/') {
if ((STRLEN)(slen + 1) >= (STRLEN)sizeof(symlink)) {
- errno = ENAMETOOLONG;
+ errno = ENAMETOOLONG;
return (NULL);
- }
+ }
symlink[slen] = '/';
symlink[slen + 1] = 0;
- }
+ }
left_len = my_strlcat(symlink, left, sizeof(left));
if (left_len >= sizeof(left)) {
errno = ENAMETOOLONG;
return (NULL);
- }
- }
+ }
+ }
left_len = my_strlcpy(left, symlink, sizeof(left));
}
}
- #endif
+#endif
}
/*