Replace Lst_Find calls with LST_FOREACH loops. This helps in
constification und simplifies the code because the one-liner predicates can be inlined into the code.
This commit is contained in:
parent
991f5121f0
commit
6ea1a0dc21
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=143810
@ -303,27 +303,6 @@ CondDoDefined(int argLen, char *arg)
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* CondStrMatch --
|
||||
* Front-end for Str_Match so it returns 0 on match and non-zero
|
||||
* on mismatch. Callback function for CondDoMake via Lst_Find
|
||||
*
|
||||
* Results:
|
||||
* 0 if string matches pattern
|
||||
*
|
||||
* Side Effects:
|
||||
* None
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static int
|
||||
CondStrMatch(const void *string, const void *pattern)
|
||||
{
|
||||
|
||||
return (!Str_Match(string, pattern));
|
||||
}
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* CondDoMake --
|
||||
@ -342,12 +321,15 @@ CondDoMake(int argLen, char *arg)
|
||||
{
|
||||
char savec = arg[argLen];
|
||||
Boolean result;
|
||||
const LstNode *ln;
|
||||
|
||||
arg[argLen] = '\0';
|
||||
if (Lst_Find(&create, arg, CondStrMatch) == NULL) {
|
||||
result = FALSE;
|
||||
} else {
|
||||
result = TRUE;
|
||||
result = FALSE;
|
||||
LST_FOREACH(ln, &create) {
|
||||
if (Str_Match(Lst_Datum(ln), arg)) {
|
||||
result = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
arg[argLen] = savec;
|
||||
return (result);
|
||||
|
@ -419,27 +419,6 @@ JobPassSig(int signo)
|
||||
sigaction(signo, &act, NULL);
|
||||
}
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* JobCmpPid --
|
||||
* Compare the pid of the job with the given pid and return 0 if they
|
||||
* are equal. This function is called from Job_CatchChildren via
|
||||
* Lst_Find to find the job descriptor of the finished job.
|
||||
*
|
||||
* Results:
|
||||
* 0 if the pid's match
|
||||
*
|
||||
* Side Effects:
|
||||
* None
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static int
|
||||
JobCmpPid(const void *job, const void *pid)
|
||||
{
|
||||
|
||||
return (*(const int *)pid - ((const Job *)job)->pid);
|
||||
}
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* JobPrintCommand --
|
||||
@ -1920,11 +1899,17 @@ Job_CatchChildren(Boolean block)
|
||||
break;
|
||||
DEBUGF(JOB, ("Process %d exited or stopped.\n", pid));
|
||||
|
||||
jnode = Lst_Find(&jobs, &pid, JobCmpPid);
|
||||
LST_FOREACH(jnode, &jobs) {
|
||||
if (((const Job *)Lst_Datum(jnode))->pid == pid)
|
||||
break;
|
||||
}
|
||||
|
||||
if (jnode == NULL) {
|
||||
if (WIFSIGNALED(status) && (WTERMSIG(status) == SIGCONT)) {
|
||||
jnode = Lst_Find(&stoppedJobs, &pid, JobCmpPid);
|
||||
LST_FOREACH(jnode, &stoppedJobs) {
|
||||
if (((const Job *)Lst_Datum(jnode))->pid == pid)
|
||||
break;
|
||||
}
|
||||
if (jnode == NULL) {
|
||||
Error("Resumed child (%d) not in table", pid);
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user