int l;
hi = hash_search(hash, name);
- if (! hi) {
+ if (!hi) {
if (++hash->nel / hash->csize > 10)
hash_rebuild(hash);
n3 = parse_expr(TC_SEQTERM);
n = chain_loop(n3);
n->l.n = n2;
- if (! n2)
+ if (!n2)
n->info = OC_EXEC;
}
break;
n = &spl->n;
if ((n->info & OPCLSMASK) == OC_REGEXP) {
regfree(re);
- regfree(ire);
+ regfree(ire); // TODO: nuke ire, use re+1?
}
if (strlen(s) > 1) {
mk_re_node(s, n, re);
int l, n = 0;
char c[4];
char *s1;
- regmatch_t pmatch[2];
+ regmatch_t pmatch[2]; // TODO: why [2]? [1] is enough...
/* in worst case, each char would be a separate field */
*slist = s1 = xzalloc(strlen(s) * 2 + 3);
c = (char) rsplitter.n.info;
rp = 0;
- if (! m) qrealloc(&m, 256, &size);
+ if (!m) qrealloc(&m, 256, &size);
do {
b = m + a;
so = eo = p;
}
} else if (c != '\0') {
s = strchr(b+pp, c);
- if (! s) s = memchr(b+pp, '\0', p - pp);
+ if (!s) s = memchr(b+pp, '\0', p - pp);
if (s) {
so = eo = s-b;
eo++;
regex_t sreg, *re;
re = as_regex(rn, &sreg);
- if (! src) src = intvar[F0];
- if (! dest) dest = intvar[F0];
+ if (!src) src = intvar[F0];
+ if (!dest) dest = intvar[F0];
i = di = 0;
sp = getvar_s(src);
sp += eo;
if (i == nm) break;
if (eo == so) {
- if (! (ds[di++] = *sp++)) break;
+ ds[di] = *sp++;
+ if (!ds[di++]) break;
}
}
/* Huh, people report that sometimes environ is NULL. Oh well. */
if (environ) for (envp = environ; *envp; envp++) {
- char *s = xstrdup(*envp);
+ /* environ is writable, thus we don't strdup it needlessly */
+ char *s = *envp;
char *s1 = strchr(s, '=');
if (s1) {
- *s1++ = '\0';
- setvar_u(findvar(iamarray(intvar[ENVIRON]), s), s1);
+ *s1 = '\0';
+ /* Both findvar and setvar_u take const char*
+ * as 2nd arg -> environment is not trashed */
+ setvar_u(findvar(iamarray(intvar[ENVIRON]), s), s1 + 1);
+ *s1 = '=';
}
- free(s);
}
opt_complementary = "v::";
opt = getopt32(argc, argv, "F:v:f:W:", &opt_F, &opt_v, &g_progname, &opt_W);