Constify the arguments to the list compare function. This temporarily
requires to make a copy of the filename in ReadMakefile and to duplicate two small functions in suff.c. This hopefully will go away when everything is constified. Submitted by: Max Okumoto <okumoto@ucsd.edu> (partly)
This commit is contained in:
parent
b697270ad8
commit
db7ce92a3c
@ -113,7 +113,6 @@ typedef struct Arch {
|
||||
size_t fnamesize; /* Size of the string table */
|
||||
} Arch;
|
||||
|
||||
static int ArchFindArchive(void *, void *);
|
||||
static void ArchFree(void *);
|
||||
static struct ar_hdr *ArchStatMember(char *, char *, Boolean);
|
||||
static FILE *ArchFindMember(char *, char *, struct ar_hdr *, char *);
|
||||
@ -435,9 +434,10 @@ Arch_ParseArchive(char **linePtr, Lst *nodeLst, GNode *ctxt)
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static int
|
||||
ArchFindArchive(void *ar, void *archName)
|
||||
ArchFindArchive(const void *ar, const void *archName)
|
||||
{
|
||||
return (strcmp((char *)archName, ((Arch *)ar)->name));
|
||||
|
||||
return (strcmp(archName, ((const Arch *)ar)->name));
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -99,7 +99,6 @@ typedef enum {
|
||||
static void CondPushBack(Token);
|
||||
static int CondGetArg(char **, char **, char *, Boolean);
|
||||
static Boolean CondDoDefined(int, char *);
|
||||
static int CondStrMatch(void *, void *);
|
||||
static Boolean CondDoMake(int, char *);
|
||||
static Boolean CondDoExists(int, char *);
|
||||
static Boolean CondDoTarget(int, char *);
|
||||
@ -307,10 +306,10 @@ CondDoDefined(int argLen, char *arg)
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static int
|
||||
CondStrMatch(void *string, void *pattern)
|
||||
CondStrMatch(const void *string, const void *pattern)
|
||||
{
|
||||
|
||||
return (!Str_Match((char *)string, (char *)pattern));
|
||||
return (!Str_Match(string, pattern));
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -189,7 +189,6 @@ static Path *dot; /* contents of current directory */
|
||||
*/
|
||||
static Hash_Table mtimes;
|
||||
|
||||
static int DirFindName(void *, void *);
|
||||
static int DirPrintWord(void *, void *);
|
||||
static int DirPrintDir(void *, void *);
|
||||
|
||||
@ -283,10 +282,10 @@ Dir_End(void)
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static int
|
||||
DirFindName(void *p, void *dname)
|
||||
DirFindName(const void *p, const void *dname)
|
||||
{
|
||||
|
||||
return (strcmp(((Path *)p)->name, dname));
|
||||
return (strcmp(((const Path *)p)->name, dname));
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -284,7 +284,6 @@ static sig_atomic_t interrupted;
|
||||
|
||||
static int JobCondPassSig(void *, void *);
|
||||
static void JobPassSig(int);
|
||||
static int JobCmpPid(void *, void *);
|
||||
static int JobPrintCommand(void *, void *);
|
||||
static int JobSaveCommand(void *, void *);
|
||||
static void JobClose(Job *);
|
||||
@ -424,10 +423,10 @@ JobPassSig(int signo)
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static int
|
||||
JobCmpPid(void *job, void *pid)
|
||||
JobCmpPid(const void *job, const void *pid)
|
||||
{
|
||||
|
||||
return (*(int *)pid - ((Job *)job)->pid);
|
||||
return (*(const int *)pid - ((const Job *)job)->pid);
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -91,7 +91,7 @@ struct Lst {
|
||||
};
|
||||
typedef struct Lst Lst;
|
||||
|
||||
typedef int CompareProc(void *, void *);
|
||||
typedef int CompareProc(const void *, const void *);
|
||||
typedef int DoProc(void *, void *);
|
||||
typedef void *DuplicateProc(void *);
|
||||
typedef void FreeProc(void *);
|
||||
@ -156,7 +156,7 @@ ReturnStatus Lst_Concat(Lst *, Lst *, int);
|
||||
/* Find an element in a list */
|
||||
#define Lst_Find(LST, D, FN) (Lst_FindFrom((LST), Lst_First(LST), (D), (FN)))
|
||||
/* Find an element starting from somewhere */
|
||||
LstNode *Lst_FindFrom(Lst *, LstNode *, void *, CompareProc *);
|
||||
LstNode *Lst_FindFrom(Lst *, LstNode *, const void *, CompareProc *);
|
||||
/*
|
||||
* See if the given datum is on the list. Returns the LstNode containing
|
||||
* the datum
|
||||
|
@ -65,7 +65,7 @@ __FBSDID("$FreeBSD$");
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
LstNode *
|
||||
Lst_FindFrom(Lst *l, LstNode *ln, void *d, CompareProc *cProc)
|
||||
Lst_FindFrom(Lst *l, LstNode *ln, const void *d, CompareProc *cProc)
|
||||
{
|
||||
LstNode *tln;
|
||||
Boolean found = FALSE;
|
||||
|
@ -121,7 +121,7 @@ Boolean jobsRunning; /* TRUE if the jobs might be running */
|
||||
|
||||
static void MainParseArgs(int, char **);
|
||||
char * chdir_verify_path(char *, char *);
|
||||
static int ReadMakefile(void *, void *);
|
||||
static int ReadMakefile(const void *, const void *);
|
||||
static void usage(void);
|
||||
|
||||
static char *curdir; /* startup directory */
|
||||
@ -904,7 +904,7 @@ main(int argc, char **argv)
|
||||
* lots
|
||||
*/
|
||||
static Boolean
|
||||
ReadMakefile(void *p, void *q __unused)
|
||||
ReadMakefile(const void *p, const void *q __unused)
|
||||
{
|
||||
char *fname; /* makefile to read */
|
||||
FILE *stream;
|
||||
@ -912,7 +912,8 @@ ReadMakefile(void *p, void *q __unused)
|
||||
char *MAKEFILE;
|
||||
int setMAKEFILE;
|
||||
|
||||
fname = p;
|
||||
/* XXX - remove this once constification is done */
|
||||
fname = estrdup(p);
|
||||
|
||||
if (!strcmp(fname, "-")) {
|
||||
Parse_File("(stdin)", stdin);
|
||||
|
@ -153,12 +153,6 @@ static Suff *emptySuff; /* The empty suffix required for POSIX
|
||||
* single-suffix transformation rules */
|
||||
|
||||
|
||||
static char *SuffStrIsPrefix(char *, char *);
|
||||
static char *SuffSuffIsSuffix(Suff *, char *);
|
||||
static int SuffSuffIsSuffixP(void *, void *);
|
||||
static int SuffSuffHasNameP(void *, void *);
|
||||
static int SuffSuffIsPrefix(void *, void *);
|
||||
static int SuffGNHasNameP(void *, void *);
|
||||
static void SuffFree(void *);
|
||||
static void SuffInsert(Lst *, Suff *);
|
||||
static void SuffRemove(Lst *, Suff *);
|
||||
@ -191,8 +185,8 @@ static int SuffPrintTrans(void *, void *);
|
||||
* None
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static char *
|
||||
SuffStrIsPrefix(char *pref, char *str)
|
||||
static char *
|
||||
SuffStrIsPrefix(const char *pref, char *str)
|
||||
{
|
||||
|
||||
while (*str && *pref == *str) {
|
||||
@ -218,9 +212,9 @@ SuffStrIsPrefix(char *pref, char *str)
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static char *
|
||||
SuffSuffIsSuffix(Suff *s, char *str)
|
||||
SuffSuffIsSuffix(const Suff *s, char *str)
|
||||
{
|
||||
char *p1; /* Pointer into suffix name */
|
||||
const char *p1; /* Pointer into suffix name */
|
||||
char *p2; /* Pointer into string being examined */
|
||||
|
||||
p1 = s->name + s->nameLen;
|
||||
@ -246,13 +240,24 @@ SuffSuffIsSuffix(Suff *s, char *str)
|
||||
* Side Effects:
|
||||
* None.
|
||||
*
|
||||
* XXX use the function above once constification is complete.
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static int
|
||||
SuffSuffIsSuffixP(void *s, void *str)
|
||||
SuffSuffIsSuffixP(const void *is, const void *str)
|
||||
{
|
||||
const Suff *s = is;
|
||||
const char *p1; /* Pointer into suffix name */
|
||||
const char *p2 = str; /* Pointer into string being examined */
|
||||
|
||||
return (!SuffSuffIsSuffix(s, str));
|
||||
p1 = s->name + s->nameLen;
|
||||
|
||||
while (p1 >= s->name && *p1 == *p2) {
|
||||
p1--;
|
||||
p2--;
|
||||
}
|
||||
|
||||
return (p1 != s->name - 1);
|
||||
}
|
||||
|
||||
/*-
|
||||
@ -269,10 +274,10 @@ SuffSuffIsSuffixP(void *s, void *str)
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static int
|
||||
SuffSuffHasNameP(void *s, void *sname)
|
||||
SuffSuffHasNameP(const void *s, const void *sname)
|
||||
{
|
||||
|
||||
return (strcmp(sname, ((Suff *)s)->name));
|
||||
return (strcmp(sname, ((const Suff *)s)->name));
|
||||
}
|
||||
|
||||
/*-
|
||||
@ -288,13 +293,22 @@ SuffSuffHasNameP(void *s, void *sname)
|
||||
*
|
||||
* Side Effects:
|
||||
* None
|
||||
*
|
||||
* XXX use the function above once constification is complete.
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static int
|
||||
SuffSuffIsPrefix(void *s, void *str)
|
||||
SuffSuffIsPrefix(const void *s, const void *istr)
|
||||
{
|
||||
const char *pref = ((const Suff *)s)->name;
|
||||
const char *str = istr;
|
||||
|
||||
return (SuffStrIsPrefix(((Suff *)s)->name, str) == NULL ? 1 : 0);
|
||||
while (*str != '\0' && *pref == *str) {
|
||||
pref++;
|
||||
str++;
|
||||
}
|
||||
|
||||
return (*pref != '\0');
|
||||
}
|
||||
|
||||
/*-
|
||||
@ -310,10 +324,10 @@ SuffSuffIsPrefix(void *s, void *str)
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static int
|
||||
SuffGNHasNameP(void *gn, void *name)
|
||||
SuffGNHasNameP(const void *gn, const void *name)
|
||||
{
|
||||
|
||||
return (strcmp(name, ((GNode *)gn)->name));
|
||||
return (strcmp(name, ((const GNode *)gn)->name));
|
||||
}
|
||||
|
||||
/*********** Maintenance Functions ************/
|
||||
|
@ -130,7 +130,6 @@ static Lst *allVars; /* List of all variables */
|
||||
#define FIND_GLOBAL 0x2 /* look in VAR_GLOBAL as well */
|
||||
#define FIND_ENV 0x4 /* look in the environment also */
|
||||
|
||||
static int VarCmp(void *, void *);
|
||||
static void VarPossiblyExpand(char **, GNode *);
|
||||
static Var *VarFind(char *, GNode *, int);
|
||||
static void VarAdd(char *, char *, GNode *);
|
||||
@ -156,10 +155,10 @@ static int VarPrintVar(void *, void *);
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static int
|
||||
VarCmp(void *v, void *name)
|
||||
VarCmp(const void *v, const void *name)
|
||||
{
|
||||
|
||||
return (strcmp(name, ((Var *)v)->name));
|
||||
return (strcmp(name, ((const Var *)v)->name));
|
||||
}
|
||||
|
||||
/*-
|
||||
|
Loading…
x
Reference in New Issue
Block a user