Style cleanup. No functional changes.
Sponsored by: The FreeBSD Foundation MFC after: 3 days Approved by: re (rgrimes)
This commit is contained in:
parent
9e7534ea78
commit
ae9e5bc0c3
@ -99,10 +99,10 @@ static void
|
||||
lmc_parse_file(char *path)
|
||||
{
|
||||
struct lmc *p;
|
||||
char *lm_map;
|
||||
struct stat st;
|
||||
ssize_t retval;
|
||||
int fd;
|
||||
char *lm_map;
|
||||
|
||||
TAILQ_FOREACH(p, &lmc_head, next) {
|
||||
if (strcmp(p->path, path) == 0)
|
||||
@ -222,17 +222,20 @@ lmc_parse(char *lm_p, size_t lm_len)
|
||||
t = f = c = NULL;
|
||||
|
||||
/* Skip over leading space */
|
||||
while (rtld_isspace(*cp)) cp++;
|
||||
while (rtld_isspace(*cp))
|
||||
cp++;
|
||||
|
||||
/* Found a comment or EOL */
|
||||
if (iseol(*cp)) continue;
|
||||
if (iseol(*cp))
|
||||
continue;
|
||||
|
||||
/* Found a constraint selector */
|
||||
if (*cp == '[') {
|
||||
cp++;
|
||||
|
||||
/* Skip leading space */
|
||||
while (rtld_isspace(*cp)) cp++;
|
||||
while (rtld_isspace(*cp))
|
||||
cp++;
|
||||
|
||||
/* Found comment, EOL or end of selector */
|
||||
if (iseol(*cp) || *cp == ']')
|
||||
@ -244,10 +247,12 @@ lmc_parse(char *lm_p, size_t lm_len)
|
||||
cp++;
|
||||
|
||||
/* Skip and zero out trailing space */
|
||||
while (rtld_isspace(*cp)) *cp++ = '\0';
|
||||
while (rtld_isspace(*cp))
|
||||
*cp++ = '\0';
|
||||
|
||||
/* Check if there is a closing brace */
|
||||
if (*cp != ']') continue;
|
||||
if (*cp != ']')
|
||||
continue;
|
||||
|
||||
/* Terminate string if there was no trailing space */
|
||||
*cp++ = '\0';
|
||||
@ -256,8 +261,10 @@ lmc_parse(char *lm_p, size_t lm_len)
|
||||
* There should be nothing except whitespace or comment
|
||||
from this point to the end of the line.
|
||||
*/
|
||||
while(rtld_isspace(*cp)) cp++;
|
||||
if (!iseol(*cp)) continue;
|
||||
while (rtld_isspace(*cp))
|
||||
cp++;
|
||||
if (!iseol(*cp))
|
||||
continue;
|
||||
|
||||
if (strlcpy(prog, c, sizeof prog) >= sizeof prog)
|
||||
continue;
|
||||
@ -267,23 +274,29 @@ lmc_parse(char *lm_p, size_t lm_len)
|
||||
|
||||
/* Parse the 'from' candidate. */
|
||||
f = cp++;
|
||||
while (!rtld_isspace(*cp) && !iseol(*cp)) cp++;
|
||||
while (!rtld_isspace(*cp) && !iseol(*cp))
|
||||
cp++;
|
||||
|
||||
/* Skip and zero out the trailing whitespace */
|
||||
while (rtld_isspace(*cp)) *cp++ = '\0';
|
||||
while (rtld_isspace(*cp))
|
||||
*cp++ = '\0';
|
||||
|
||||
/* Found a comment or EOL */
|
||||
if (iseol(*cp)) continue;
|
||||
if (iseol(*cp))
|
||||
continue;
|
||||
|
||||
/* Parse 'to' mapping */
|
||||
t = cp++;
|
||||
while (!rtld_isspace(*cp) && !iseol(*cp)) cp++;
|
||||
while (!rtld_isspace(*cp) && !iseol(*cp))
|
||||
cp++;
|
||||
|
||||
/* Skip and zero out the trailing whitespace */
|
||||
while (rtld_isspace(*cp)) *cp++ = '\0';
|
||||
while (rtld_isspace(*cp))
|
||||
*cp++ = '\0';
|
||||
|
||||
/* Should be no extra tokens at this point */
|
||||
if (!iseol(*cp)) continue;
|
||||
if (!iseol(*cp))
|
||||
continue;
|
||||
|
||||
*cp = '\0';
|
||||
if (strcmp(f, "includedir") == 0)
|
||||
@ -296,7 +309,7 @@ lmc_parse(char *lm_p, size_t lm_len)
|
||||
}
|
||||
|
||||
static void
|
||||
lm_free (struct lm_list *lml)
|
||||
lm_free(struct lm_list *lml)
|
||||
{
|
||||
struct lm *lm;
|
||||
|
||||
@ -309,11 +322,10 @@ lm_free (struct lm_list *lml)
|
||||
free(lm->t);
|
||||
free(lm);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
lm_fini (void)
|
||||
lm_fini(void)
|
||||
{
|
||||
struct lmp *lmp;
|
||||
struct lmc *p;
|
||||
@ -334,11 +346,10 @@ lm_fini (void)
|
||||
lm_free(&lmp->lml);
|
||||
free(lmp);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
lm_add (const char *p, const char *f, const char *t)
|
||||
lm_add(const char *p, const char *f, const char *t)
|
||||
{
|
||||
struct lm_list *lml;
|
||||
struct lm *lm;
|
||||
@ -359,7 +370,7 @@ lm_add (const char *p, const char *f, const char *t)
|
||||
}
|
||||
|
||||
char *
|
||||
lm_find (const char *p, const char *f)
|
||||
lm_find(const char *p, const char *f)
|
||||
{
|
||||
struct lm_list *lml;
|
||||
char *t;
|
||||
@ -380,14 +391,15 @@ lm_find (const char *p, const char *f)
|
||||
lml = lmp_find("$DEFAULT$");
|
||||
if (lml != NULL)
|
||||
return (lml_find(lml, f));
|
||||
else
|
||||
return (NULL);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* Given a libmap translation list and a library name, return the
|
||||
replacement library, or NULL */
|
||||
/*
|
||||
* Given a libmap translation list and a library name, return the
|
||||
* replacement library, or NULL.
|
||||
*/
|
||||
char *
|
||||
lm_findn (const char *p, const char *f, const int n)
|
||||
lm_findn(const char *p, const char *f, const int n)
|
||||
{
|
||||
char pathbuf[64], *s, *t;
|
||||
|
||||
@ -404,37 +416,43 @@ lm_findn (const char *p, const char *f, const int n)
|
||||
}
|
||||
|
||||
static char *
|
||||
lml_find (struct lm_list *lmh, const char *f)
|
||||
lml_find(struct lm_list *lmh, const char *f)
|
||||
{
|
||||
struct lm *lm;
|
||||
|
||||
dbg("%s(%p, \"%s\")", __func__, lmh, f);
|
||||
|
||||
TAILQ_FOREACH(lm, lmh, lm_link)
|
||||
TAILQ_FOREACH(lm, lmh, lm_link) {
|
||||
if (strcmp(f, lm->f) == 0)
|
||||
return (lm->t);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* Given an executable name, return a pointer to the translation list or
|
||||
NULL if no matches */
|
||||
/*
|
||||
* Given an executable name, return a pointer to the translation list or
|
||||
* NULL if no matches.
|
||||
*/
|
||||
static struct lm_list *
|
||||
lmp_find (const char *n)
|
||||
lmp_find(const char *n)
|
||||
{
|
||||
struct lmp *lmp;
|
||||
|
||||
dbg("%s(\"%s\")", __func__, n);
|
||||
|
||||
TAILQ_FOREACH(lmp, &lmp_head, lmp_link)
|
||||
TAILQ_FOREACH(lmp, &lmp_head, lmp_link) {
|
||||
if ((lmp->type == T_EXACT && strcmp(n, lmp->p) == 0) ||
|
||||
(lmp->type == T_DIRECTORY && strncmp(n, lmp->p, strlen(lmp->p)) == 0) ||
|
||||
(lmp->type == T_BASENAME && strcmp(quickbasename(n), lmp->p) == 0))
|
||||
(lmp->type == T_DIRECTORY && strncmp(n, lmp->p,
|
||||
strlen(lmp->p)) == 0) ||
|
||||
(lmp->type == T_BASENAME && strcmp(quickbasename(n),
|
||||
lmp->p) == 0))
|
||||
return (&lmp->lml);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static struct lm_list *
|
||||
lmp_init (char *n)
|
||||
lmp_init(char *n)
|
||||
{
|
||||
struct lmp *lmp;
|
||||
|
||||
@ -442,7 +460,7 @@ lmp_init (char *n)
|
||||
|
||||
lmp = xmalloc(sizeof(struct lmp));
|
||||
lmp->p = n;
|
||||
if (n[strlen(n)-1] == '/')
|
||||
if (n[strlen(n) - 1] == '/')
|
||||
lmp->type = T_DIRECTORY;
|
||||
else if (strchr(n,'/') == NULL)
|
||||
lmp->type = T_BASENAME;
|
||||
@ -454,15 +472,18 @@ lmp_init (char *n)
|
||||
return (&lmp->lml);
|
||||
}
|
||||
|
||||
/* libc basename is overkill. Return a pointer to the character after the
|
||||
last /, or the original string if there are no slashes. */
|
||||
/*
|
||||
* libc basename is overkill. Return a pointer to the character after
|
||||
* the last /, or the original string if there are no slashes.
|
||||
*/
|
||||
static const char *
|
||||
quickbasename (const char *path)
|
||||
quickbasename(const char *path)
|
||||
{
|
||||
const char *p = path;
|
||||
for (; *path; path++) {
|
||||
const char *p;
|
||||
|
||||
for (p = path; *path != '\0'; path++) {
|
||||
if (*path == '/')
|
||||
p = path+1;
|
||||
p = path + 1;
|
||||
}
|
||||
return (p);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user