pcre2grep: avoid mixing declarations with code

Since d5a61ee8 (Patch to detect (and ignore) symlink loops in
pcre2grep., 2021-08-28), code will fail to build in a strict C89
compiler.

Reformat slightly to make it C89 compatible again.
This commit is contained in:
Carlo Marcelo Arenas Belón 2021-10-26 16:35:35 -07:00
parent 78494b1871
commit d2691591c5
1 changed files with 8 additions and 3 deletions

View File

@ -3361,18 +3361,23 @@ if (isdirectory(pathname))
because that affects the output from pcre2grep. */
#ifdef HAVE_REALPATH
{
char resolvedpath[PATH_MAX];
BOOL isSame;
size_t rlen;
if (realpath(childpath, resolvedpath) == NULL)
continue; /* This path is invalid - we can skip processing this */
BOOL isSame = strcmp(pathname, resolvedpath) == 0;
isSame = strcmp(pathname, resolvedpath) == 0;
if (isSame) continue; /* We have a recursion */
size_t rlen = strlen(resolvedpath);
rlen = strlen(resolvedpath);
if (rlen++ < sizeof(resolvedpath) - 3)
{
BOOL contained;
strcat(resolvedpath, "/");
BOOL contained = strncmp(pathname, resolvedpath, rlen) == 0;
contained = strncmp(pathname, resolvedpath, rlen) == 0;
if (contained) continue; /* We have a recursion */
}
}
#endif /* HAVE_REALPATH */
frc = grep_or_recurse(childpath, dir_recurse, FALSE);