f7d95a075c
and linting procedure: 1. Remove useless sub-expression: - if (*start || (!ifsspc && start > string && (nulonly || 1))) { + if (*start || (!ifsspc && start > string)) { The sub-expression "(nulonly || 1)" always evaluates to true and according to CVS logs seems to be just a left-over from some debugging and introduced by accident. Removing the sub-expression doesn't change semantics and a code inspection showed that the variable "nulonly" is also not necessary here in any way (and the expression would require fixing instead of removing). 2. Remove dead code: - if (backslash && c == '\\') { - if (read(STDIN_FILENO, &c, 1) != 1) { - status = 1; - break; - } - STPUTC(c, p); - } else if (ap[1] != NULL && strchr(ifs, c) != NULL) { + if (ap[1] != NULL && strchr(ifs, c) != NULL) { Inspection of the control and data flow showed that variable "backslash" is always false (0) when the "if"-expression is evaluated, hence the whole block is effectively dead code. Additionally, the skipping of characters after a backslash is already performed correctly a few lines above, so this code is also not needed at all. According to the CVS logs and the ASH 0.2 sources, this code existed in this way already since its early days. 3. Cleanup Style: - ! trap[signo][0] == '\0' && + ! (trap[signo][0] == '\0') && The expression wants to ensure the trap is not assigned the empty string. But the "!" operator has higher precedence than "==", so the comparison should be put into parenthesis to form the intended way of expression. Nevertheless the code was effectively not really broken as both particular NUL comparisons are semantically equal, of course. But the parenthesized version is a lot more intuitive. 4. Remove shadowing variable declaration: - char *q; The declaration of symbol "q" hides another identical declaration of "q" in the same context. As the other "q" is already reused multiple times and also can be reused again without negative side-effects, just remove the shadowing declaration. 5. Just small cosmetics: - if (ifsset() != 0) + if (ifsset()) The ifsset() macro is already coded by returning the boolean result of a comparison operator, so no need to compare this boolean result again against a numerical value. This also aligns the macros usage to the remaining existing code. Reviewed by: stefanf@ |
||
---|---|---|
.. | ||
bltin | ||
funcs | ||
alias.c | ||
alias.h | ||
arith_lex.l | ||
arith.h | ||
arith.y | ||
builtins.def | ||
cd.c | ||
cd.h | ||
error.c | ||
error.h | ||
eval.c | ||
eval.h | ||
exec.c | ||
exec.h | ||
expand.c | ||
expand.h | ||
histedit.c | ||
init.h | ||
input.c | ||
input.h | ||
jobs.c | ||
jobs.h | ||
mail.c | ||
mail.h | ||
main.c | ||
main.h | ||
Makefile | ||
memalloc.c | ||
memalloc.h | ||
miscbltin.c | ||
mkbuiltins | ||
mkinit.c | ||
mknodes.c | ||
mksyntax.c | ||
mktokens | ||
myhistedit.h | ||
mystring.c | ||
mystring.h | ||
nodes.c.pat | ||
nodetypes | ||
options.c | ||
options.h | ||
output.c | ||
output.h | ||
parser.c | ||
parser.h | ||
redir.c | ||
redir.h | ||
sh.1 | ||
shell.h | ||
show.c | ||
show.h | ||
TOUR | ||
trap.c | ||
trap.h | ||
var.c | ||
var.h |