Some more easy constification.
Submitted by: Max Okumoto <okumoto@ucsd.edu>
This commit is contained in:
parent
c673c301c6
commit
5f05e672b6
@ -119,8 +119,9 @@ typedef struct Arch {
|
||||
size_t fnamesize; /* Size of the string table */
|
||||
} Arch;
|
||||
|
||||
static struct ar_hdr *ArchStatMember(char *, char *, Boolean);
|
||||
static FILE *ArchFindMember(char *, char *, struct ar_hdr *, char *);
|
||||
static struct ar_hdr *ArchStatMember(const char *, const char *, Boolean);
|
||||
static FILE *ArchFindMember(const char *, const char *, struct ar_hdr *,
|
||||
const char *);
|
||||
#if defined(__svr4__) || defined(__SVR4) || defined(__ELF__)
|
||||
#define SVR4ARCHIVES
|
||||
static int ArchSVR4Entry(Arch *, char *, size_t, FILE *);
|
||||
@ -432,7 +433,7 @@ ArchFindArchive(const void *ar, const void *archName)
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static struct ar_hdr *
|
||||
ArchStatMember(char *archive, char *member, Boolean hash)
|
||||
ArchStatMember(const char *archive, const char *member, Boolean hash)
|
||||
{
|
||||
#define AR_MAX_NAME_LEN (sizeof(arh.ar_name) - 1)
|
||||
FILE * arch; /* Stream to archive */
|
||||
@ -736,11 +737,12 @@ ArchSVR4Entry(Arch *ar, char *name, size_t size, FILE *arch)
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static FILE *
|
||||
ArchFindMember(char *archive, char *member, struct ar_hdr *arhPtr, char *mode)
|
||||
ArchFindMember(const char *archive, const char *member, struct ar_hdr *arhPtr,
|
||||
const char *mode)
|
||||
{
|
||||
FILE * arch; /* Stream to archive */
|
||||
int size; /* Size of archive member */
|
||||
char *cp; /* Useful character pointer */
|
||||
const char *cp; /* Useful character pointer */
|
||||
char magic[SARMAG];
|
||||
size_t len, tlen;
|
||||
|
||||
|
@ -94,14 +94,14 @@ static void CompatInterrupt(int);
|
||||
static int CompatMake(void *, void *);
|
||||
static int shellneed(char *);
|
||||
|
||||
static char *sh_builtin[] = {
|
||||
static const char *const sh_builtin[] = {
|
||||
"alias", "cd", "eval", "exec", "exit", "read", "set", "ulimit",
|
||||
"unalias", "umask", "unset", "wait", ":", 0};
|
||||
"unalias", "umask", "unset", "wait", ":", NULL};
|
||||
|
||||
static void
|
||||
CompatInit(void)
|
||||
{
|
||||
char *cp; /* Pointer to string of shell meta-characters */
|
||||
const char *cp; /* Pointer to string of shell meta-characters */
|
||||
|
||||
for (cp = "#=|^(){};&<>*?[]:$`\\\n"; *cp != '\0'; cp++) {
|
||||
meta[(unsigned char)*cp] = 1;
|
||||
@ -197,7 +197,8 @@ CompatInterrupt (int signo)
|
||||
static int
|
||||
shellneed (char *cmd)
|
||||
{
|
||||
char **av, **p;
|
||||
char **av;
|
||||
const char *const *p;
|
||||
int ac;
|
||||
|
||||
av = brk_string(cmd, &ac, TRUE);
|
||||
|
@ -977,7 +977,7 @@ Dir_MTime(GNode *gn)
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Dir_AddDir(Lst *path, char *name)
|
||||
Dir_AddDir(Lst *path, const char *name)
|
||||
{
|
||||
LstNode *ln; /* node in case Path structure is found */
|
||||
Path *p; /* pointer to new Path structure */
|
||||
@ -1076,7 +1076,7 @@ Dir_CopyDir(void *p)
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
char *
|
||||
Dir_MakeFlags(char *flag, Lst *path)
|
||||
Dir_MakeFlags(const char *flag, Lst *path)
|
||||
{
|
||||
char *str; /* the string which will be returned */
|
||||
char *tstr; /* the current directory preceded by 'flag' */
|
||||
|
@ -62,8 +62,8 @@ Boolean Dir_HasWildcards(const char *);
|
||||
void Dir_Expand(char *, struct Lst *, struct Lst *);
|
||||
char *Dir_FindFile(char *, struct Lst *);
|
||||
int Dir_MTime(struct GNode *);
|
||||
void Dir_AddDir(struct Lst *, char *);
|
||||
char *Dir_MakeFlags(char *, struct Lst *);
|
||||
void Dir_AddDir(struct Lst *, const char *);
|
||||
char *Dir_MakeFlags(const char *, struct Lst *);
|
||||
void Dir_ClearPath(struct Lst *);
|
||||
void Dir_Concat(struct Lst *, struct Lst *);
|
||||
void Dir_PrintDirectories(void);
|
||||
|
@ -238,7 +238,7 @@ static fd_set outputs; /* Set of descriptors of pipes connected to
|
||||
|
||||
STATIC GNode *lastNode; /* The node for which output was most recently
|
||||
* produced. */
|
||||
STATIC char *targFmt; /* Format string to use to head output from a
|
||||
STATIC const char *targFmt; /* Format string to use to head output from a
|
||||
* job when it's not the most-recent job heard
|
||||
* from */
|
||||
|
||||
@ -479,7 +479,7 @@ JobPrintCommand(void *cmdp, void *jobp)
|
||||
Boolean errOff = FALSE; /* true if we turned error checking
|
||||
* off before printing the command
|
||||
* and need to turn it back on */
|
||||
char *cmdTemplate; /* Template to use when printing the
|
||||
const char *cmdTemplate; /* Template to use when printing the
|
||||
* command */
|
||||
char *cmdStart; /* Start of expanded command */
|
||||
LstNode *cmdNode; /* Node for replacing the command */
|
||||
|
@ -137,7 +137,7 @@ Lst envFirstVars = Lst_Initializer(envFirstVars);
|
||||
Boolean jobsRunning; /* TRUE if the jobs might be running */
|
||||
|
||||
static void MainParseArgs(int, char **);
|
||||
char * chdir_verify_path(char *, char *);
|
||||
char *chdir_verify_path(const char *, char *);
|
||||
static int ReadMakefile(const void *, const void *);
|
||||
static void usage(void);
|
||||
|
||||
@ -148,7 +148,7 @@ static char *objdir; /* where we chdir'ed to */
|
||||
* Append a flag with an optional argument to MAKEFLAGS and MFLAGS
|
||||
*/
|
||||
static void
|
||||
MFLAGS_append(char *flag, char *arg)
|
||||
MFLAGS_append(const char *flag, char *arg)
|
||||
{
|
||||
char *str;
|
||||
|
||||
@ -410,19 +410,19 @@ Main_ParseArgLine(char *line, int mflags)
|
||||
}
|
||||
|
||||
char *
|
||||
chdir_verify_path(char *path, char *obpath)
|
||||
chdir_verify_path(const char *path, char *obpath)
|
||||
{
|
||||
struct stat sb;
|
||||
|
||||
if (stat(path, &sb) == 0 && S_ISDIR(sb.st_mode)) {
|
||||
if (chdir(path) == -1 || getcwd(obpath, MAXPATHLEN) == NULL) {
|
||||
warn("warning: %s", path);
|
||||
return (0);
|
||||
return (NULL);
|
||||
}
|
||||
return (obpath);
|
||||
}
|
||||
|
||||
return (0);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -476,15 +476,16 @@ int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
Boolean outOfDate = TRUE; /* FALSE if all targets up to date */
|
||||
struct stat sa;
|
||||
char *p, *p1, *path, *pathp;
|
||||
char *p, *p1, *pathp;
|
||||
char *path;
|
||||
char mdpath[MAXPATHLEN];
|
||||
char obpath[MAXPATHLEN];
|
||||
char cdpath[MAXPATHLEN];
|
||||
char *machine = getenv("MACHINE");
|
||||
char *machine_arch = getenv("MACHINE_ARCH");
|
||||
char *machine_cpu = getenv("MACHINE_CPU");
|
||||
const char *machine = getenv("MACHINE");
|
||||
const char *machine_arch = getenv("MACHINE_ARCH");
|
||||
const char *machine_cpu = getenv("MACHINE_CPU");
|
||||
char *cp = NULL, *start;
|
||||
|
||||
/* avoid faults on read-only strings */
|
||||
static char syspath[] = _PATH_DEFSYSPATH;
|
||||
|
||||
@ -652,8 +653,12 @@ main(int argc, char **argv)
|
||||
if (getcwd(curdir, MAXPATHLEN) == NULL)
|
||||
err(2, NULL);
|
||||
|
||||
{
|
||||
struct stat sa;
|
||||
|
||||
if (stat(curdir, &sa) == -1)
|
||||
err(2, "%s", curdir);
|
||||
}
|
||||
|
||||
/*
|
||||
* The object directory location is determined using the
|
||||
@ -1013,7 +1018,7 @@ found:
|
||||
* The string must be freed by the caller.
|
||||
*/
|
||||
char *
|
||||
Cmd_Exec(char *cmd, char **error)
|
||||
Cmd_Exec(char *cmd, const char **error)
|
||||
{
|
||||
char *args[4]; /* Args for invoking the shell */
|
||||
int fds[2]; /* Pipe streams */
|
||||
|
@ -44,6 +44,6 @@
|
||||
|
||||
/* main.c */
|
||||
void Main_ParseArgLine(char *, int);
|
||||
char *Cmd_Exec(char *, char **);
|
||||
char *Cmd_Exec(char *, const char **);
|
||||
|
||||
#endif /* nonints_h_33c5dafb */
|
||||
|
@ -188,7 +188,7 @@ static GNode *predecessor;
|
||||
* keyword is used as a source ("0" if the keyword isn't special as a source)
|
||||
*/
|
||||
static struct {
|
||||
char *name; /* Name of keyword */
|
||||
const char *name; /* Name of keyword */
|
||||
ParseSpecial spec; /* Type when used as a target */
|
||||
int op; /* Operator when used as a source */
|
||||
} parseKeywords[] = {
|
||||
@ -939,15 +939,15 @@ ParseDoDependency (char *line)
|
||||
* allow on this line...
|
||||
*/
|
||||
if (specType != Not && specType != ExPath) {
|
||||
Boolean warn = FALSE;
|
||||
Boolean warnFlag = FALSE;
|
||||
|
||||
while ((*cp != '!') && (*cp != ':') && *cp) {
|
||||
if (*cp != ' ' && *cp != '\t') {
|
||||
warn = TRUE;
|
||||
warnFlag = TRUE;
|
||||
}
|
||||
cp++;
|
||||
}
|
||||
if (warn) {
|
||||
if (warnFlag) {
|
||||
Parse_Error(PARSE_WARNING, "Extra target ignored");
|
||||
}
|
||||
} else {
|
||||
@ -1433,7 +1433,8 @@ Parse_DoVar(char *line, GNode *ctxt)
|
||||
} else if (type == VAR_SHELL) {
|
||||
Boolean freeCmd = FALSE; /* TRUE if the command needs to be freed, i.e.
|
||||
* if any variable expansion was performed */
|
||||
char *res, *error;
|
||||
char *res;
|
||||
const char *error;
|
||||
|
||||
if (strchr(cp, '$') != NULL) {
|
||||
/*
|
||||
|
@ -1609,7 +1609,8 @@ SuffFindArchiveDeps(GNode *gn, Lst *slst)
|
||||
char *eoarch; /* End of archive portion */
|
||||
char *eoname; /* End of member portion */
|
||||
GNode *mem; /* Node for member */
|
||||
static char *copy[] = { /* Variables to be copied from the member node */
|
||||
/* Variables to be copied from the member node */
|
||||
static char *const copy[] = {
|
||||
TARGET, /* Must be first */
|
||||
PREFIX, /* Must be second */
|
||||
};
|
||||
|
@ -137,7 +137,7 @@ Targ_Init(void)
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
GNode *
|
||||
Targ_NewGN(char *name)
|
||||
Targ_NewGN(const char *name)
|
||||
{
|
||||
GNode *gn;
|
||||
|
||||
@ -183,7 +183,7 @@ Targ_NewGN(char *name)
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
GNode *
|
||||
Targ_FindNode(char *name, int flags)
|
||||
Targ_FindNode(const char *name, int flags)
|
||||
{
|
||||
GNode *gn; /* node in that element */
|
||||
Hash_Entry *he; /* New or used hash entry for node */
|
||||
|
@ -58,8 +58,8 @@ struct GNode;
|
||||
struct Lst;
|
||||
|
||||
void Targ_Init(void);
|
||||
struct GNode *Targ_NewGN(char *);
|
||||
struct GNode *Targ_FindNode(char *, int);
|
||||
struct GNode *Targ_NewGN(const char *);
|
||||
struct GNode *Targ_FindNode(const char *, int);
|
||||
void Targ_FindList(struct Lst *, struct Lst *, int);
|
||||
Boolean Targ_Ignore(struct GNode *);
|
||||
Boolean Targ_Silent(struct GNode *);
|
||||
|
@ -137,8 +137,8 @@ GNode *VAR_CMD; /* variables defined on the command-line */
|
||||
#define FIND_ENV 0x4 /* look in the environment also */
|
||||
|
||||
static void VarPossiblyExpand(char **, GNode *);
|
||||
static Var *VarFind(char *, GNode *, int);
|
||||
static void VarAdd(char *, char *, GNode *);
|
||||
static Var *VarFind(const char *, GNode *, int);
|
||||
static void VarAdd(const char *, const char *, GNode *);
|
||||
static void VarDelete(void *);
|
||||
static char *VarGetPattern(GNode *, int, char **, int, int *, size_t *,
|
||||
VarPattern *);
|
||||
@ -209,7 +209,7 @@ VarPossiblyExpand(char **name, GNode *ctxt)
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static Var *
|
||||
VarFind(char *name, GNode *ctxt, int flags)
|
||||
VarFind(const char *name, GNode *ctxt, int flags)
|
||||
{
|
||||
Boolean localCheckEnvFirst;
|
||||
LstNode *var;
|
||||
@ -326,7 +326,7 @@ VarFind(char *name, GNode *ctxt, int flags)
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static void
|
||||
VarAdd(char *name, char *val, GNode *ctxt)
|
||||
VarAdd(const char *name, const char *val, GNode *ctxt)
|
||||
{
|
||||
Var *v;
|
||||
int len;
|
||||
@ -337,7 +337,7 @@ VarAdd(char *name, char *val, GNode *ctxt)
|
||||
|
||||
len = val ? strlen(val) : 0;
|
||||
v->val = Buf_Init(len+1);
|
||||
Buf_AddBytes(v->val, len, (Byte *)val);
|
||||
Buf_AddBytes(v->val, len, (const Byte *)val);
|
||||
|
||||
v->flags = 0;
|
||||
|
||||
@ -415,7 +415,7 @@ Var_Delete(char *name, GNode *ctxt)
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Var_Set(char *name, char *val, GNode *ctxt)
|
||||
Var_Set(char *name, const char *val, GNode *ctxt)
|
||||
{
|
||||
Var *v;
|
||||
|
||||
@ -467,7 +467,7 @@ Var_Set(char *name, char *val, GNode *ctxt)
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Var_Append(char *name, char *val, GNode *ctxt)
|
||||
Var_Append(char *name, const char *val, GNode *ctxt)
|
||||
{
|
||||
Var *v;
|
||||
|
||||
@ -1538,7 +1538,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, size_t *lengthPtr,
|
||||
#ifdef SUNSHCMD
|
||||
case 's':
|
||||
if (tstr[1] == 'h' && (tstr[2] == endc || tstr[2] == ':')) {
|
||||
char *error;
|
||||
const char *error;
|
||||
newStr = Cmd_Exec(str, &error);
|
||||
if (error)
|
||||
Error(error, str);
|
||||
@ -1748,22 +1748,21 @@ Var_Subst(char *var, char *str, GNode *ctxt, Boolean undefErr)
|
||||
* Skip as many characters as possible -- either to the end of
|
||||
* the string or to the next dollar sign (variable invocation).
|
||||
*/
|
||||
char *cp;
|
||||
char *cp;
|
||||
|
||||
for (cp = str++; *str != '$' && *str != '\0'; str++)
|
||||
continue;
|
||||
Buf_AddBytes(buf, str - cp, (Byte *)cp);
|
||||
Buf_AddBytes(buf, str - cp, (const Byte *)cp);
|
||||
} else {
|
||||
if (var != NULL) {
|
||||
int expand;
|
||||
for (;;) {
|
||||
if (str[1] != '(' && str[1] != '{') {
|
||||
if (str[1] != *var || var[1] != '\0') {
|
||||
Buf_AddBytes(buf, 2, (Byte *)str);
|
||||
Buf_AddBytes(buf, 2, (const Byte *)str);
|
||||
str += 2;
|
||||
expand = FALSE;
|
||||
}
|
||||
else
|
||||
} else
|
||||
expand = TRUE;
|
||||
break;
|
||||
}
|
||||
@ -1783,7 +1782,7 @@ Var_Subst(char *var, char *str, GNode *ctxt, Boolean undefErr)
|
||||
* the nested one
|
||||
*/
|
||||
if (*p == '$') {
|
||||
Buf_AddBytes(buf, p - str, (Byte *)str);
|
||||
Buf_AddBytes(buf, p - str, (const Byte *)str);
|
||||
str = p;
|
||||
continue;
|
||||
}
|
||||
|
@ -110,8 +110,8 @@ Boolean VarRESubstitute(const char *, Boolean, struct Buffer *, void *);
|
||||
Boolean VarSubstitute(const char *, Boolean, struct Buffer *, void *);
|
||||
|
||||
void Var_Delete(char *, struct GNode *);
|
||||
void Var_Set(char *, char *, struct GNode *);
|
||||
void Var_Append(char *, char *, struct GNode *);
|
||||
void Var_Set(char *, const char *, struct GNode *);
|
||||
void Var_Append(char *, const char *, struct GNode *);
|
||||
Boolean Var_Exists(char *, struct GNode *);
|
||||
char *Var_Value(char *, struct GNode *, char **);
|
||||
char *Var_Quote(const char *);
|
||||
|
@ -77,7 +77,7 @@ VarHead(const char *word, Boolean addSpace, Buffer *buf, void *dummy __unused)
|
||||
if (addSpace) {
|
||||
Buf_AddByte(buf, (Byte)' ');
|
||||
}
|
||||
Buf_AddBytes(buf, slash - word, (Byte *)word);
|
||||
Buf_AddBytes(buf, slash - word, (const Byte *)word);
|
||||
} else {
|
||||
/*
|
||||
* If no directory part, give . (q.v. the POSIX standard)
|
||||
@ -182,9 +182,9 @@ VarRoot(const char *word, Boolean addSpace, Buffer *buf, void *dummy __unused)
|
||||
|
||||
dot = strrchr(word, '.');
|
||||
if (dot != NULL) {
|
||||
Buf_AddBytes(buf, dot - word, (Byte *)word);
|
||||
Buf_AddBytes(buf, dot - word, (const Byte *)word);
|
||||
} else {
|
||||
Buf_AddBytes(buf, strlen(word), (Byte *)word);
|
||||
Buf_AddBytes(buf, strlen(word), (const Byte *)word);
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user