summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2011-10-07 18:00:39 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2011-10-07 18:00:39 -0700
commit0ecf5f3251033ab6efa1a0d881f75ed9ce60b5a4 (patch)
treee61a1007a79f0d678aca72222918cec96e9f157c
parent97ae52f80f9e382917889bde1913367572e89012 (diff)
Add const attributes to fix gcc -Wwrite-strings warnings
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--def.h15
-rw-r--r--main.c8
-rw-r--r--parse.c18
3 files changed, 21 insertions, 20 deletions
diff --git a/def.h b/def.h
index 6251d91..ce344a8 100644
--- a/def.h
+++ b/def.h
@@ -134,10 +134,10 @@ struct filepointer {
int match(const char *str, const char * const *list);
char *base_name(const char *file);
char *getnextline(struct filepointer *fp);
-struct symtab **slookup(char *symbol, struct inclist *file);
-struct symtab **isdefined(char *symbol, struct inclist *file,
+struct symtab **slookup(const char *symbol, struct inclist *file);
+struct symtab **isdefined(const char *symbol, struct inclist *file,
struct inclist **srcfile);
-struct symtab **fdefined(char *symbol, struct inclist *file,
+struct symtab **fdefined(const char *symbol, struct inclist *file,
struct inclist **srcfile);
struct filepointer *getfile(const char *file);
void included_by(struct inclist *ip,
@@ -150,9 +150,10 @@ struct inclist *inc_path(const char *file, const char *include,
void freefile(struct filepointer *fp);
-void define2(char *name, char *val, struct inclist *file);
+void define2(const char *name, const char *val,
+ struct inclist *file);
void define(char *def, struct inclist *file);
-void undefine(char *symbol, struct inclist *file);
+void undefine(const char *symbol, struct inclist *file);
int find_includes(struct filepointer *filep,
struct inclist *file,
struct inclist *file_red,
@@ -186,8 +187,8 @@ extern const char **includedirsnext;
extern const char * const directives[];
extern char *notdotdot[ ];
-extern char *objprefix;
-extern char *objsuffix;
+extern const char *objprefix;
+extern const char *objsuffix;
extern int width;
extern boolean printed;
extern boolean verbose;
diff --git a/main.c b/main.c
index 617191c..f1a093a 100644
--- a/main.c
+++ b/main.c
@@ -99,9 +99,9 @@ const char *includedirs[ MAXDIRS + 1 ],
char *notdotdot[ MAXDIRS ];
static int cmdinc_count = 0;
static char *cmdinc_list[ 2 * MAXINCFILES ];
-char *objprefix = "";
-char *objsuffix = OBJSUFFIX;
-static char *startat = "# DO NOT DELETE";
+const char *objprefix = "";
+const char *objsuffix = OBJSUFFIX;
+static const char *startat = "# DO NOT DELETE";
int width = 78;
static boolean append = FALSE;
boolean printed = FALSE;
@@ -159,7 +159,7 @@ main(int argc, char *argv[])
char *makefile = NULL;
struct filepointer *filecontent;
const struct symtab *psymp = predefs;
- char *endmarker = NULL;
+ const char *endmarker = NULL;
char *defincdir = NULL;
char **undeflist = NULL;
int numundefs = 0, i;
diff --git a/parse.c b/parse.c
index a4277e7..0496388 100644
--- a/parse.c
+++ b/parse.c
@@ -251,7 +251,7 @@ deftype (char *line, struct filepointer *filep,
}
struct symtab **
-fdefined(char *symbol, struct inclist *file, struct inclist **srcfile)
+fdefined(const char *symbol, struct inclist *file, struct inclist **srcfile)
{
struct inclist **ip;
struct symtab **val;
@@ -282,7 +282,7 @@ fdefined(char *symbol, struct inclist *file, struct inclist **srcfile)
}
struct symtab **
-isdefined(char *symbol, struct inclist *file, struct inclist **srcfile)
+isdefined(const char *symbol, struct inclist *file, struct inclist **srcfile)
{
struct symtab **val;
@@ -313,7 +313,7 @@ zero_value(char *filename,
}
void
-define2(char *name, char *val, struct inclist *file)
+define2(const char *name, const char *val, struct inclist *file)
{
int first, last, below;
register struct symtab **sp = NULL, **dest;
@@ -339,8 +339,8 @@ define2(char *name, char *val, struct inclist *file)
while (last >= first)
{
/* Fast inline binary search */
- register char *s1;
- register char *s2;
+ register const char *s1;
+ register const char *s2;
register int middle = (first + last) / 2;
/* Fast inline strchr() */
@@ -417,7 +417,7 @@ define(char *def, struct inclist *file)
}
struct symtab **
-slookup(char *symbol, struct inclist *file)
+slookup(const char *symbol, struct inclist *file)
{
register int first = 0;
register int last;
@@ -430,8 +430,8 @@ slookup(char *symbol, struct inclist *file)
while (last >= first)
{
/* Fast inline binary search */
- register char *s1;
- register char *s2;
+ register const char *s1;
+ register const char *s2;
register int middle = (first + last) / 2;
/* Fast inline strchr() */
@@ -529,7 +529,7 @@ merge2defines(struct inclist *file1, struct inclist *file2)
}
void
-undefine(char *symbol, struct inclist *file)
+undefine(const char *symbol, struct inclist *file)
{
register struct symtab **ptr;
struct inclist *srcfile;