rpcgen: Clarify behaviour for idx

The re-initialisation of idx in the later else branch is a bit hidden,
and results in deviation from the earlier two paths. Use more consistent
code instead to make it abundantly clear what's going on.
This commit is contained in:
Jessica Clarke 2023-07-13 06:22:52 +01:00
parent 7cd7a32041
commit 9d843ba324

View File

@ -270,18 +270,18 @@ add_warning(void)
static void
prepend_cpp(void)
{
int idx = 1;
int idx = 0;
const char *var;
char *dupvar, *s, *t;
if (CPP != NULL)
insarg(0, CPP);
insarg(idx++, CPP);
else if ((var = getenv("RPCGEN_CPP")) == NULL)
insarg(0, "/usr/bin/cpp");
insarg(idx++, "/usr/bin/cpp");
else {
/* Parse command line in a rudimentary way */
dupvar = xstrdup(var);
for (s = dupvar, idx = 0; (t = strsep(&s, " \t")) != NULL; ) {
for (s = dupvar; (t = strsep(&s, " \t")) != NULL; ) {
if (t[0])
insarg(idx++, t);
}