make(1): replace *line with line[0]

Since a line is not an iterator and since the expression *line typically
means "the current element", not "the first character", replacing *line
with line[0] more directly expresses the idea of accessing the first
character of a string.
This commit is contained in:
rillig 2020-12-13 02:01:43 +00:00
parent 40711a6e7b
commit e774dc5acc
3 changed files with 21 additions and 15 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: job.c,v 1.385 2020/12/12 18:53:53 rillig Exp $ */
/* $NetBSD: job.c,v 1.386 2020/12/13 02:01:43 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -143,7 +143,7 @@
#include "trace.h"
/* "@(#)job.c 8.2 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: job.c,v 1.385 2020/12/12 18:53:53 rillig Exp $");
MAKE_RCSID("$NetBSD: job.c,v 1.386 2020/12/13 02:01:43 rillig Exp $");
/*
* A shell defines how the commands are run. All commands for a target are
@ -2354,6 +2354,7 @@ Job_ParseShell(char *line)
Boolean fullSpec = FALSE;
Shell *sh;
/* XXX: don't use line as an iterator variable */
pp_skip_whitespace(&line);
free(shellArgv);

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.495 2020/12/12 18:53:53 rillig Exp $ */
/* $NetBSD: main.c,v 1.496 2020/12/13 02:01:43 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -109,7 +109,7 @@
#include "trace.h"
/* "@(#)main.c 8.3 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: main.c,v 1.495 2020/12/12 18:53:53 rillig Exp $");
MAKE_RCSID("$NetBSD: main.c,v 1.496 2020/12/13 02:01:43 rillig Exp $");
#if defined(MAKE_NATIVE) && !defined(lint)
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
"The Regents of the University of California. "
@ -683,6 +683,7 @@ Main_ParseArgLine(const char *line)
if (line == NULL)
return;
/* XXX: don't use line as an iterator variable */
for (; *line == ' '; ++line)
continue;
if (line[0] == '\0')

View File

@ -1,4 +1,4 @@
/* $NetBSD: parse.c,v 1.477 2020/12/13 01:51:08 rillig Exp $ */
/* $NetBSD: parse.c,v 1.478 2020/12/13 02:01:43 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -117,7 +117,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: parse.c,v 1.477 2020/12/13 01:51:08 rillig Exp $");
MAKE_RCSID("$NetBSD: parse.c,v 1.478 2020/12/13 02:01:43 rillig Exp $");
/* types and constants */
@ -1099,7 +1099,7 @@ ParseDependencyTargetWord(const char **pp, const char *lstart)
/* Handle special targets like .PATH, .DEFAULT, .BEGIN, .ORDER. */
static void
ParseDoDependencyTargetSpecial(ParseSpecial *inout_specType,
const char *line,
const char *line, /* XXX: bad name */
SearchPathList **inout_paths)
{
switch (*inout_specType) {
@ -1164,7 +1164,8 @@ ParseDoDependencyTargetSpecial(ParseSpecial *inout_specType,
* Call on the suffix module to give us a path to modify.
*/
static Boolean
ParseDoDependencyTargetPath(const char *line, SearchPathList **inout_paths)
ParseDoDependencyTargetPath(const char *line, /* XXX: bad name */
SearchPathList **inout_paths)
{
SearchPath *path;
@ -1186,12 +1187,13 @@ ParseDoDependencyTargetPath(const char *line, SearchPathList **inout_paths)
* See if it's a special target and if so set specType to match it.
*/
static Boolean
ParseDoDependencyTarget(const char *line, ParseSpecial *inout_specType,
ParseDoDependencyTarget(const char *line, /* XXX: bad name */
ParseSpecial *inout_specType,
GNodeType *out_tOp, SearchPathList **inout_paths)
{
int keywd;
if (!(*line == '.' && ch_isupper(line[1])))
if (!(line[0] == '.' && ch_isupper(line[1])))
return TRUE;
/*
@ -1221,7 +1223,8 @@ ParseDoDependencyTarget(const char *line, ParseSpecial *inout_specType,
}
static void
ParseDoDependencyTargetMundane(char *line, StringList *curTargs)
ParseDoDependencyTargetMundane(char *line, /* XXX: bad name */
StringList *curTargs)
{
if (Dir_HasWildcards(line)) {
/*
@ -1666,6 +1669,7 @@ ParseDoDependency(char *line)
/*
* First, grind through the targets.
*/
/* XXX: don't use line as an iterator variable */
if (!ParseDoDependencyTargets(&cp, &line, lstart, &specType, &tOp,
&paths, &curTargs))
goto out;
@ -2257,11 +2261,11 @@ Parse_include_file(char *file, Boolean isSystem, Boolean depinc, Boolean silent)
}
static void
ParseDoInclude(char *line)
ParseDoInclude(char *line /* XXX: bad name */)
{
char endc; /* the character which ends the file spec */
char *cp; /* current position in file spec */
Boolean silent = *line != 'i';
Boolean silent = line[0] != 'i';
char *file = line + (silent ? 8 : 7);
/* Skip to delimiter character so we know where to look */
@ -2302,7 +2306,7 @@ ParseDoInclude(char *line)
(void)Var_Subst(file, VAR_CMDLINE, VARE_WANTRES, &file);
/* TODO: handle errors */
Parse_include_file(file, endc == '>', *line == 'd', silent);
Parse_include_file(file, endc == '>', line[0] == 'd', silent);
free(file);
}
@ -3128,7 +3132,7 @@ ParseLine(char *line)
if (line[0] == '.' && ParseDirective(line))
return;
if (*line == '\t') {
if (line[0] == '\t') {
ParseLine_ShellCommand(line + 1);
return;
}