This is more efficient than using the ! operator on older platforms.
link = 0;
}
- i = 1 - i;
+ i ^= 1;
/*
* Skip trailing whitespace...
cups_array_t *products, /* Product array */
*psversions, /* PSVersion array */
*cups_languages; /* cupsLanguages array */
- int new_ppd; /* Is this a new PPD? */
struct /* LanguageVersion translation table */
{
const char *version, /* LanguageVersion string */
* Record the PPD file...
*/
- new_ppd = !ppd;
-
- if (new_ppd)
+ if (!ppd)
{
/*
* Add new PPD file...
* Execute all of the filters...
*/
- pids = cupsArrayNew((cups_array_func_t)compare_pids, NULL);
- current = 0;
- filterfds[0][0] = -1;
+ pids = cupsArrayNew((cups_array_func_t)compare_pids, NULL);
+ current = 1;
+ filterfds[0][0] = infile ? -1 : 0;
filterfds[0][1] = -1;
filterfds[1][0] = -1;
filterfds[1][1] = -1;
- if (!infile)
- filterfds[0][0] = 0;
-
for (filter = (mime_filter_t *)cupsArrayFirst(filters);
filter;
- filter = next, current = 1 - current)
+ filter = next, current ^= 1)
{
next = (mime_filter_t *)cupsArrayNext(filters);
snprintf(program, sizeof(program), "%s/filter/%s", ServerBin,
filter->filter);
- if (filterfds[!current][1] > 1)
+ if (filterfds[current][1] > 1)
{
- close(filterfds[1 - current][0]);
- close(filterfds[1 - current][1]);
+ close(filterfds[current][0]);
+ close(filterfds[current][1]);
- filterfds[1 - current][0] = -1;
- filterfds[1 - current][1] = -1;
+ filterfds[current][0] = -1;
+ filterfds[current][1] = -1;
}
if (next)
- open_pipe(filterfds[1 - current]);
+ open_pipe(filterfds[current]);
else if (outfile)
{
- filterfds[1 - current][1] = open(outfile, O_CREAT | O_TRUNC | O_WRONLY,
- 0666);
+ filterfds[current][1] = open(outfile, O_CREAT | O_TRUNC | O_WRONLY, 0666);
- if (filterfds[1 - current][1] < 0)
+ if (filterfds[current][1] < 0)
fprintf(stderr, "ERROR: Unable to create \"%s\" - %s\n", outfile,
strerror(errno));
}
else
- filterfds[1 - current][1] = 1;
+ filterfds[current][1] = 1;
pid = exec_filter(program, (char **)argv, (char **)envp,
- filterfds[current][0], filterfds[1 - current][1]);
+ filterfds[current ^ 1][0], filterfds[current][1]);
if (pid > 0)
{
filterfds[slot][1] = job->print_pipes[1];
}
- pid = cupsdStartProcess(command, argv, envp, filterfds[!slot][0],
+ pid = cupsdStartProcess(command, argv, envp, filterfds[slot ^ 1][0],
filterfds[slot][1], job->status_pipes[1],
job->back_pipes[0], job->side_pipes[0], 0,
job->profile, job, job->filters + i);
- cupsdClosePipe(filterfds[!slot]);
+ cupsdClosePipe(filterfds[slot ^ 1]);
if (pid == 0)
{
argv[6] = NULL;
}
- slot = !slot;
+ slot ^= 1;
}
cupsArrayDelete(filters);
filterfds[slot][0] = -1;
filterfds[slot][1] = -1;
- pid = cupsdStartProcess(command, argv, envp, filterfds[!slot][0],
+ pid = cupsdStartProcess(command, argv, envp, filterfds[slot ^ 1][0],
filterfds[slot][1], job->status_pipes[1],
job->back_pipes[1], job->side_pipes[1],
backroot, job->bprofile, job, &(job->backend));
FilterLevel -= job->cost;
job->cost = 0;
- for (slot = 0; slot < 2; slot ++)
- cupsdClosePipe(filterfds[slot]);
+ cupsdClosePipe(filterfds[0]);
+ cupsdClosePipe(filterfds[1]);
cupsArrayDelete(filters);
* short then don't compare - it can't match...
*/
- if ((rules->offset + rules->length) > (fb->offset + fb->length))
- {
- result = 0;
- }
- else
+ result = 0;
+ if ((rules->offset + rules->length) <= (fb->offset + fb->length))
{
if (fb->length > rules->region)
region = rules->region - rules->length;
else
region = fb->length - rules->length;
- for (n = 0; n < region; n ++)
- if ((result = (memcmp(fb->buffer + rules->offset - fb->offset + n, rules->value.stringv, (size_t)rules->length) == 0)) != 0)
- break;
- }
+ for (n = 0; n < region; n ++)
+ if (!memcmp(fb->buffer + rules->offset - fb->offset + n, rules->value.stringv, (size_t)rules->length))
+ {
+ result = 1;
+ break;
+ }
+ }
break;
default :