Skip to content

Commit

Permalink
Constify.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwsw committed Nov 7, 2023
1 parent efae1e9 commit 98acbb0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
6 changes: 3 additions & 3 deletions decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -745,13 +745,13 @@ public constant char * lgetenv(constant char *var)

a = cmd_decode(list_var_tables, var, &s);
if (a == EV_OK)
return (s); /*{{const-issue}}*/
return (s);
s = getenv(var);
if (s != NULL && *s != '\0')
return (s); /*{{const-issue}}*/
return (s);
a = cmd_decode(list_sysvar_tables, var, &s);
if (a == EV_OK)
return (s); /*{{const-issue}}*/
return (s);
return (NULL);
}

Expand Down
29 changes: 15 additions & 14 deletions tags.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

#if TAGS

public char ztags[] = "tags";
public char *tags = ztags;
public constant char ztags[] = "tags";
public constant char *tags = ztags;

static int total;
static int curseq;
Expand Down Expand Up @@ -44,13 +44,13 @@ enum {
T_GPATH /* 'GPATH': path name (global) */
};

static enum tag_result findctag(char *tag);
static enum tag_result findgtag(char *tag, int type);
static enum tag_result findctag(constant char *tag);
static enum tag_result findgtag(constant char *tag, int type);
static char *nextgtag(void);
static char *prevgtag(void);
static POSITION ctagsearch(void);
static POSITION gtagsearch(void);
static int getentry(char *buf, char **tag, char **file, char **line);
static int getentry(char *buf, constant char **tag, constant char **file, constant char **line);

/*
* The list of tags generated by the last findgtag() call.
Expand Down Expand Up @@ -111,7 +111,7 @@ public void cleantags(void)
/*
* Create a new tag entry.
*/
static struct tag * maketagent(char *name, char *file, LINENUM linenum, char *pattern, int endline)
static struct tag * maketagent(constant char *name, constant char *file, LINENUM linenum, constant char *pattern, int endline)
{
struct tag *tp;

Expand Down Expand Up @@ -163,7 +163,7 @@ public int gettagtype(void)
* and "tagpattern" to the search pattern which should be used
* to find the tag.
*/
public void findtag(char *tag)
public void findtag(constant char *tag)
{
int type = gettagtype();
enum tag_result result;
Expand Down Expand Up @@ -250,7 +250,7 @@ public int curr_tag(void)
* Find tags in the "tags" file.
* Sets curtag to the first tag entry.
*/
static enum tag_result findctag(char *tag)
static enum tag_result findctag(constant char *tag)
{
char *p;
char *q;
Expand Down Expand Up @@ -481,7 +481,7 @@ static POSITION ctagsearch(void)
* for future use by gtagsearch().
* Sets curtag to the first tag entry.
*/
static enum tag_result findgtag(char *tag, int type)
static enum tag_result findgtag(constant char *tag, int type)
{
char buf[1024];
FILE *fp;
Expand Down Expand Up @@ -536,12 +536,11 @@ static enum tag_result findgtag(char *tag, int type)
/* Get our data from global(1). */
qtag = shell_quote(tag);
if (qtag == NULL)
qtag = tag;
qtag = save(tag);
command = (char *) ecalloc(strlen(cmd) + strlen(flag) +
strlen(qtag) + 5, sizeof(char));
sprintf(command, "%s -x%s %s", cmd, flag, qtag);
if (qtag != tag)
free(qtag);
free(qtag);
fp = popen(command, "r");
free(command);
#endif
Expand All @@ -550,7 +549,9 @@ static enum tag_result findgtag(char *tag, int type)
{
while (fgets(buf, sizeof(buf), fp))
{
char *name, *file, *line;
constant char *name;
constant char *file;
constant char *line;
int len;

if (sigs)
Expand Down Expand Up @@ -706,7 +707,7 @@ static POSITION gtagsearch(void)
* The tag, file, and line will each be NUL-terminated pointers
* into buf.
*/
static int getentry(char *buf, char **tag, char **file, char **line)
static int getentry(char *buf, constant char **tag, constant char **file, constant char **line)
{
char *p = buf;

Expand Down

0 comments on commit 98acbb0

Please sign in to comment.