- Fix style(9) bugs in glob.c
Approved by: jilles
This commit is contained in:
parent
0d6d372c03
commit
855291741d
@ -232,9 +232,9 @@ glob(const char * __restrict pattern, int flags,
|
||||
*bufnext = EOS;
|
||||
|
||||
if (flags & GLOB_BRACE)
|
||||
return globexp1(patbuf, pglob, &limit);
|
||||
return (globexp1(patbuf, pglob, &limit));
|
||||
else
|
||||
return glob0(patbuf, pglob, &limit);
|
||||
return (glob0(patbuf, pglob, &limit));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -304,7 +304,7 @@ globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, int *rv, size_t *l
|
||||
/* Non matching braces; just glob the pattern */
|
||||
if (i != 0 || *pe == EOS) {
|
||||
*rv = glob0(patbuf, pglob, limit);
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
for (i = 0, pl = pm = ptr; pm <= pe; pm++)
|
||||
@ -361,7 +361,7 @@ globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, int *rv, size_t *l
|
||||
break;
|
||||
}
|
||||
*rv = 0;
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
@ -378,7 +378,7 @@ globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, glob_t *pglob)
|
||||
Char *b, *eb;
|
||||
|
||||
if (*pattern != TILDE || !(pglob->gl_flags & GLOB_TILDE))
|
||||
return pattern;
|
||||
return (pattern);
|
||||
|
||||
/*
|
||||
* Copy up to the end of the string or /
|
||||
@ -403,7 +403,7 @@ globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, glob_t *pglob)
|
||||
(pwd = getpwuid(getuid())) != NULL)
|
||||
h = pwd->pw_dir;
|
||||
else
|
||||
return pattern;
|
||||
return (pattern);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -411,7 +411,7 @@ globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, glob_t *pglob)
|
||||
* Expand a ~user
|
||||
*/
|
||||
if ((pwd = getpwnam((char*) patbuf)) == NULL)
|
||||
return pattern;
|
||||
return (pattern);
|
||||
else
|
||||
h = pwd->pw_dir;
|
||||
}
|
||||
@ -425,7 +425,7 @@ globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, glob_t *pglob)
|
||||
continue;
|
||||
*b = EOS;
|
||||
|
||||
return patbuf;
|
||||
return (patbuf);
|
||||
}
|
||||
|
||||
|
||||
@ -512,20 +512,20 @@ glob0(const Char *pattern, glob_t *pglob, size_t *limit)
|
||||
if (((pglob->gl_flags & GLOB_NOCHECK) ||
|
||||
((pglob->gl_flags & GLOB_NOMAGIC) &&
|
||||
!(pglob->gl_flags & GLOB_MAGCHAR))))
|
||||
return(globextend(pattern, pglob, limit));
|
||||
return (globextend(pattern, pglob, limit));
|
||||
else
|
||||
return(GLOB_NOMATCH);
|
||||
return (GLOB_NOMATCH);
|
||||
}
|
||||
if (!(pglob->gl_flags & GLOB_NOSORT))
|
||||
qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc,
|
||||
pglob->gl_pathc - oldpathc, sizeof(char *), compare);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
compare(const void *p, const void *q)
|
||||
{
|
||||
return(strcmp(*(char **)p, *(char **)q));
|
||||
return (strcmp(*(char **)p, *(char **)q));
|
||||
}
|
||||
|
||||
static int
|
||||
@ -535,8 +535,8 @@ glob1(Char *pattern, glob_t *pglob, size_t *limit)
|
||||
|
||||
/* A null pathname is invalid -- POSIX 1003.1 sect. 2.4. */
|
||||
if (*pattern == EOS)
|
||||
return(0);
|
||||
return(glob2(pathbuf, pathbuf, pathbuf + MAXPATHLEN - 1,
|
||||
return (0);
|
||||
return (glob2(pathbuf, pathbuf, pathbuf + MAXPATHLEN - 1,
|
||||
pattern, pglob, limit));
|
||||
}
|
||||
|
||||
@ -561,7 +561,7 @@ glob2(Char *pathbuf, Char *pathend, Char *pathend_last, Char *pattern,
|
||||
if (*pattern == EOS) { /* End of pattern? */
|
||||
*pathend = EOS;
|
||||
if (g_lstat(pathbuf, &sb, pglob))
|
||||
return(0);
|
||||
return (0);
|
||||
|
||||
if (((pglob->gl_flags & GLOB_MARK) &&
|
||||
pathend[-1] != SEP) && (S_ISDIR(sb.st_mode)
|
||||
@ -574,7 +574,7 @@ glob2(Char *pathbuf, Char *pathend, Char *pathend_last, Char *pattern,
|
||||
*pathend = EOS;
|
||||
}
|
||||
++pglob->gl_matchc;
|
||||
return(globextend(pathbuf, pglob, limit));
|
||||
return (globextend(pathbuf, pglob, limit));
|
||||
}
|
||||
|
||||
/* Find end of next segment, copy tentatively to pathend. */
|
||||
@ -597,8 +597,8 @@ glob2(Char *pathbuf, Char *pathend, Char *pathend_last, Char *pattern,
|
||||
*pathend++ = *pattern++;
|
||||
}
|
||||
} else /* Need expansion, recurse. */
|
||||
return(glob3(pathbuf, pathend, pathend_last, pattern, p,
|
||||
pglob, limit));
|
||||
return (glob3(pathbuf, pathend, pathend_last, pattern,
|
||||
p, pglob, limit));
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
@ -635,7 +635,7 @@ glob3(Char *pathbuf, Char *pathend, Char *pathend_last,
|
||||
pglob->gl_flags & GLOB_ERR)
|
||||
return (GLOB_ABORTED);
|
||||
}
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
err = 0;
|
||||
@ -683,7 +683,7 @@ glob3(Char *pathbuf, Char *pathend, Char *pathend_last,
|
||||
(*pglob->gl_closedir)(dirp);
|
||||
else
|
||||
closedir(dirp);
|
||||
return(err);
|
||||
return (err);
|
||||
}
|
||||
|
||||
|
||||
@ -723,7 +723,7 @@ globextend(const Char *path, glob_t *pglob, size_t *limit)
|
||||
free(pglob->gl_pathv);
|
||||
pglob->gl_pathv = NULL;
|
||||
}
|
||||
return(GLOB_NOSPACE);
|
||||
return (GLOB_NOSPACE);
|
||||
}
|
||||
|
||||
if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) {
|
||||
@ -745,7 +745,7 @@ globextend(const Char *path, glob_t *pglob, size_t *limit)
|
||||
pathv[pglob->gl_offs + pglob->gl_pathc++] = copy;
|
||||
}
|
||||
pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
|
||||
return(copy == NULL ? GLOB_NOSPACE : 0);
|
||||
return (copy == NULL ? GLOB_NOSPACE : 0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -765,20 +765,20 @@ match(Char *name, Char *pat, Char *patend)
|
||||
switch (c & M_MASK) {
|
||||
case M_ALL:
|
||||
if (pat == patend)
|
||||
return(1);
|
||||
return (1);
|
||||
do
|
||||
if (match(name, pat, patend))
|
||||
return(1);
|
||||
return (1);
|
||||
while (*name++ != EOS);
|
||||
return(0);
|
||||
return (0);
|
||||
case M_ONE:
|
||||
if (*name++ == EOS)
|
||||
return(0);
|
||||
return (0);
|
||||
break;
|
||||
case M_SET:
|
||||
ok = 0;
|
||||
if ((k = *name++) == EOS)
|
||||
return(0);
|
||||
return (0);
|
||||
if ((negate_range = ((*pat & M_MASK) == M_NOT)) != EOS)
|
||||
++pat;
|
||||
while (((c = *pat++) & M_MASK) != M_END)
|
||||
@ -793,15 +793,15 @@ match(Char *name, Char *pat, Char *patend)
|
||||
} else if (c == k)
|
||||
ok = 1;
|
||||
if (ok == negate_range)
|
||||
return(0);
|
||||
return (0);
|
||||
break;
|
||||
default:
|
||||
if (*name++ != c)
|
||||
return(0);
|
||||
return (0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return(*name == EOS);
|
||||
return (*name == EOS);
|
||||
}
|
||||
|
||||
/* Free allocated data belonging to a glob_t structure. */
|
||||
@ -834,9 +834,9 @@ g_opendir(Char *str, glob_t *pglob)
|
||||
}
|
||||
|
||||
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
|
||||
return((*pglob->gl_opendir)(buf));
|
||||
return ((*pglob->gl_opendir)(buf));
|
||||
|
||||
return(opendir(buf));
|
||||
return (opendir(buf));
|
||||
}
|
||||
|
||||
static int
|
||||
@ -850,7 +850,7 @@ g_lstat(Char *fn, struct stat *sb, glob_t *pglob)
|
||||
}
|
||||
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
|
||||
return((*pglob->gl_lstat)(buf, sb));
|
||||
return(lstat(buf, sb));
|
||||
return (lstat(buf, sb));
|
||||
}
|
||||
|
||||
static int
|
||||
@ -863,8 +863,8 @@ g_stat(Char *fn, struct stat *sb, glob_t *pglob)
|
||||
return (-1);
|
||||
}
|
||||
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
|
||||
return((*pglob->gl_stat)(buf, sb));
|
||||
return(stat(buf, sb));
|
||||
return ((*pglob->gl_stat)(buf, sb));
|
||||
return (stat(buf, sb));
|
||||
}
|
||||
|
||||
static const Char *
|
||||
|
Loading…
Reference in New Issue
Block a user