diff options
author | harti <harti@FreeBSD.org> | 2004-12-08 12:59:27 +0000 |
---|---|---|
committer | harti <harti@FreeBSD.org> | 2004-12-08 12:59:27 +0000 |
commit | 4dcbfdf87679aeeb6ab14b3272848b094c225c1a (patch) | |
tree | be6ee2e0eedc8795d8fb1d4031e9daf8fdaee4ee /usr.bin/make | |
parent | 96f1216abd0ae24d31b1c660fdbeeb17f1cca646 (diff) | |
download | FreeBSD-src-4dcbfdf87679aeeb6ab14b3272848b094c225c1a.zip FreeBSD-src-4dcbfdf87679aeeb6ab14b3272848b094c225c1a.tar.gz |
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)
Diffstat (limited to 'usr.bin/make')
-rw-r--r-- | usr.bin/make/arch.c | 6 | ||||
-rw-r--r-- | usr.bin/make/cond.c | 5 | ||||
-rw-r--r-- | usr.bin/make/dir.c | 5 | ||||
-rw-r--r-- | usr.bin/make/job.c | 5 | ||||
-rw-r--r-- | usr.bin/make/lst.h | 4 | ||||
-rw-r--r-- | usr.bin/make/lst.lib/lstFindFrom.c | 2 | ||||
-rw-r--r-- | usr.bin/make/main.c | 7 | ||||
-rw-r--r-- | usr.bin/make/suff.c | 50 | ||||
-rw-r--r-- | usr.bin/make/var.c | 5 |
9 files changed, 50 insertions, 39 deletions
diff --git a/usr.bin/make/arch.c b/usr.bin/make/arch.c index 0a73e8d..cd5ffc0 100644 --- a/usr.bin/make/arch.c +++ b/usr.bin/make/arch.c @@ -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)); } /*- diff --git a/usr.bin/make/cond.c b/usr.bin/make/cond.c index e290c90..dad3869 100644 --- a/usr.bin/make/cond.c +++ b/usr.bin/make/cond.c @@ -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)); } /*- diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c index 861da59..c4ed050 100644 --- a/usr.bin/make/dir.c +++ b/usr.bin/make/dir.c @@ -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)); } /*- diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c index 5088c2e..adde86e 100644 --- a/usr.bin/make/job.c +++ b/usr.bin/make/job.c @@ -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); } /*- diff --git a/usr.bin/make/lst.h b/usr.bin/make/lst.h index a8bc102..5324f24 100644 --- a/usr.bin/make/lst.h +++ b/usr.bin/make/lst.h @@ -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 diff --git a/usr.bin/make/lst.lib/lstFindFrom.c b/usr.bin/make/lst.lib/lstFindFrom.c index 3853829..ecdbc3e 100644 --- a/usr.bin/make/lst.lib/lstFindFrom.c +++ b/usr.bin/make/lst.lib/lstFindFrom.c @@ -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; diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index e15030f..6ec5a66 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -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); diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c index 3101357..715cdd8 100644 --- a/usr.bin/make/suff.c +++ b/usr.bin/make/suff.c @@ -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 */ + + p1 = s->name + s->nameLen; - return (!SuffSuffIsSuffix(s, str)); + 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; + + while (*str != '\0' && *pref == *str) { + pref++; + str++; + } - return (SuffStrIsPrefix(((Suff *)s)->name, str) == NULL ? 1 : 0); + 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 ************/ diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index cefc81c..8fb594b 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -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)); } /*- |