remove all but these __CRAZY=Yes build warnings:

main.c: In function 'main':
 main.c:208: warning: cast discards qualifiers from pointer target type
 main.c:329: warning: cast discards qualifiers from pointer target type

no warnings at autoconf time left either; will take care of these two later
(might revisit changes from this commit), maybe change declararion for the
builtins to have their argv[] be const strings, and go through strict type
and qualifier checking again. this'll further improve stability.

XXX these changes might have introduced (more?) memory leaks,
XXX someone who knows about these tools should verify with
XXX automatic memory usage analysers (valgrind?)

still passes testsuite
This commit is contained in:
tg 2006-11-12 14:58:16 +00:00
parent fa7407a37c
commit 151d913115
9 changed files with 80 additions and 76 deletions

8
edit.c
View File

@ -5,7 +5,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.72 2006/11/10 07:52:01 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/edit.c,v 1.73 2006/11/12 14:58:13 tg Exp $");
/* tty driver characters we are interested in */ /* tty driver characters we are interested in */
typedef struct { typedef struct {
@ -367,8 +367,8 @@ struct path_order_info {
static int static int
path_order_cmp(const void *aa, const void *bb) path_order_cmp(const void *aa, const void *bb)
{ {
const struct path_order_info *a = (const struct path_order_info *) aa; const struct path_order_info *a = (const struct path_order_info *)aa;
const struct path_order_info *b = (const struct path_order_info *) bb; const struct path_order_info *b = (const struct path_order_info *)bb;
int t; int t;
t = strcmp(a->word + a->base, b->word + b->base); t = strcmp(a->word + a->base, b->word + b->base);
@ -5415,7 +5415,7 @@ static void
x_vi_zotc(int c) x_vi_zotc(int c)
{ {
if (Flag(FVISHOW8) && (c & 0x80)) { if (Flag(FVISHOW8) && (c & 0x80)) {
x_puts((u_char *)"M-"); x_puts((const u_char *)"M-");
c &= 0x7f; c &= 0x7f;
} }
if (c < ' ' || c == 0x7f) { if (c < ' ' || c == 0x7f) {

6
eval.c
View File

@ -2,7 +2,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.18 2006/11/10 07:52:02 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/eval.c,v 1.19 2006/11/12 14:58:14 tg Exp $");
/* /*
* string expansion * string expansion
@ -267,7 +267,7 @@ expand(char *cp, /* input word */
char *str, *end; char *str, *end;
sp = varname - 2; /* restore sp */ sp = varname - 2; /* restore sp */
end = (char *) wdscan(sp, CSUBST); end = sp + (wdscan(sp, CSUBST) - sp);
/* ({) the } or x is already skipped */ /* ({) the } or x is already skipped */
endc = *end; endc = *end;
*end = EOS; *end = EOS;
@ -345,7 +345,7 @@ expand(char *cp, /* input word */
} }
} else } else
/* skip word */ /* skip word */
sp = (char *) wdscan(sp, CSUBST); sp += wdscan(sp, CSUBST) - sp;
continue; continue;
} }
case CSUBST: /* only get here if expanding word */ case CSUBST: /* only get here if expanding word */

35
exec.c
View File

@ -2,7 +2,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.19 2006/11/10 06:16:24 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/exec.c,v 1.20 2006/11/12 14:58:14 tg Exp $");
static int comexec(struct op *, struct tbl *volatile, char **, static int comexec(struct op *, struct tbl *volatile, char **,
int volatile); int volatile);
@ -666,7 +666,7 @@ static void
scriptexec(struct op *tp, char **ap) scriptexec(struct op *tp, char **ap)
{ {
static char execshell[] = "/bin/sh"; static char execshell[] = "/bin/sh";
char *sh; const char *sh;
sh = str_val(global("EXECSHELL")); sh = str_val(global("EXECSHELL"));
if (sh && *sh) if (sh && *sh)
@ -675,7 +675,7 @@ scriptexec(struct op *tp, char **ap)
sh = execshell; sh = execshell;
*tp->args-- = tp->str; *tp->args-- = tp->str;
*tp->args = sh; *tp->args = str_save(sh, ATEMP);
execve(tp->args[0], tp->args, ap); execve(tp->args[0], tp->args, ap);
@ -802,7 +802,7 @@ findcom(const char *name, int flags)
struct tbl *tp = NULL, *tbi; struct tbl *tp = NULL, *tbi;
int insert = Flag(FTRACKALL); /* insert if not found */ int insert = Flag(FTRACKALL); /* insert if not found */
char *fpath; /* for function autoloading */ char *fpath; /* for function autoloading */
char *npath; const char *npath;
if (strchr(name, '/') != NULL) { if (strchr(name, '/') != NULL) {
insert = 0; insert = 0;
@ -858,7 +858,7 @@ findcom(const char *name, int flags)
npath = search(name, flags & FC_DEFPATH ? def_path : path, npath = search(name, flags & FC_DEFPATH ? def_path : path,
X_OK, &tp->u2.errno_); X_OK, &tp->u2.errno_);
if (npath) { if (npath) {
tp->val.s = tp == &temp ? npath : str_save(npath, APERM); tp->val.s = str_save(npath, APERM);
tp->flag |= ISSET|ALLOC; tp->flag |= ISSET|ALLOC;
} else if ((flags & FC_FUNC) && } else if ((flags & FC_FUNC) &&
(fpath = str_val(global("FPATH"))) != null && (fpath = str_val(global("FPATH"))) != null &&
@ -924,7 +924,7 @@ search_access(const char *lpath, int mode,
/* /*
* search for command with PATH * search for command with PATH
*/ */
char * const char *
search(const char *name, const char *lpath, search(const char *name, const char *lpath,
int mode, /* R_OK or X_OK */ int mode, /* R_OK or X_OK */
int *errnop) /* set if candidate found, but not suitable */ int *errnop) /* set if candidate found, but not suitable */
@ -938,7 +938,7 @@ search(const char *name, const char *lpath,
*errnop = 0; *errnop = 0;
if (strchr(name, '/')) { if (strchr(name, '/')) {
if (search_access(name, mode, errnop) == 0) if (search_access(name, mode, errnop) == 0)
return (char *) name; return (name);
return NULL; return NULL;
} }
@ -1195,8 +1195,10 @@ herein(const char *content, int sub)
static char * static char *
do_selectargs(char **ap, bool print_menu) do_selectargs(char **ap, bool print_menu)
{ {
static const char *const read_args[] = { static char read_args0[] = "read",
"read", "-r", "REPLY", NULL read_args1[] = "-r", read_args2[] = "REPLY",
*read_args[] = {
read_args0, read_args1, read_args2, NULL
}; };
char *s; char *s;
int i, argct; int i, argct;
@ -1212,7 +1214,7 @@ do_selectargs(char **ap, bool print_menu)
if (print_menu || !*str_val(global("REPLY"))) if (print_menu || !*str_val(global("REPLY")))
pr_menu(ap); pr_menu(ap);
shellf("%s", str_val(global("PS3"))); shellf("%s", str_val(global("PS3")));
if (call_builtin(findcom("read", FC_BI), (char **) read_args)) if (call_builtin(findcom("read", FC_BI), read_args))
return NULL; return NULL;
s = str_val(global("REPLY")); s = str_val(global("REPLY"));
if (*s) { if (*s) {
@ -1229,13 +1231,14 @@ struct select_menu_info {
int num_width; int num_width;
}; };
static char *select_fmt_entry(void *arg, int i, char *buf, int buflen); static char *select_fmt_entry(const void *, int, char *, int);
/* format a single select menu item */ /* format a single select menu item */
static char * static char *
select_fmt_entry(void *arg, int i, char *buf, int buflen) select_fmt_entry(const void *arg, int i, char *buf, int buflen)
{ {
struct select_menu_info *smi = (struct select_menu_info *) arg; const struct select_menu_info *smi =
(const struct select_menu_info *)arg;
shf_snprintf(buf, buflen, "%*d) %s", shf_snprintf(buf, buflen, "%*d) %s",
smi->num_width, i + 1, smi->args[i]); smi->num_width, i + 1, smi->args[i]);
@ -1286,10 +1289,10 @@ pr_menu(char *const *ap)
/* XXX: horrible kludge to fit within the framework */ /* XXX: horrible kludge to fit within the framework */
static char *plain_fmt_entry(void *arg, int i, char *buf, int buflen); static char *plain_fmt_entry(const void *, int, char *, int);
static char * static char *
plain_fmt_entry(void *arg, int i, char *buf, int buflen) plain_fmt_entry(const void *arg, int i, char *buf, int buflen)
{ {
shf_snprintf(buf, buflen, "%s", ((char *const *)arg)[i]); shf_snprintf(buf, buflen, "%s", ((char *const *)arg)[i]);
return buf; return buf;
@ -1306,7 +1309,7 @@ pr_list(char *const *ap)
i = strlen(*pp); i = strlen(*pp);
nwidth = (i > nwidth) ? i : nwidth; nwidth = (i > nwidth) ? i : nwidth;
} }
print_columns(shl_out, n, plain_fmt_entry, (void *) ap, nwidth + 1, 0); print_columns(shl_out, n, plain_fmt_entry, (const void *)ap, nwidth + 1, 0);
return n; return n;
} }

25
funcs.c
View File

@ -5,7 +5,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.36 2006/11/10 07:52:02 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.37 2006/11/12 14:58:14 tg Exp $");
int int
c_cd(char **wp) c_cd(char **wp)
@ -854,9 +854,8 @@ c_alias(char **wp)
/* "hash -r" means reset all the tracked aliases.. */ /* "hash -r" means reset all the tracked aliases.. */
if (rflag) { if (rflag) {
static const char *const args[] = { static char args0[] = "unalias", args1[] = "-ta",
"unalias", "-ta", NULL *args[] = { args0, args1, NULL };
};
if (!tflag || *wp) { if (!tflag || *wp) {
shprintf("alias: -r flag can only be used with -t" shprintf("alias: -r flag can only be used with -t"
@ -864,7 +863,7 @@ c_alias(char **wp)
return 1; return 1;
} }
ksh_getopt_reset(&builtin_opt, GF_ERROR); ksh_getopt_reset(&builtin_opt, GF_ERROR);
return c_unalias((char **) args); return c_unalias(args);
} }
if (*wp == NULL) { if (*wp == NULL) {
@ -886,7 +885,7 @@ c_alias(char **wp)
for (; *wp != NULL; wp++) { for (; *wp != NULL; wp++) {
char *alias = *wp; char *alias = *wp;
char *val = strchr(alias, '='); char *val = strchr(alias, '=');
char *newval; const char *newval;
struct tbl *ap; struct tbl *ap;
int h; int h;
@ -1071,13 +1070,13 @@ struct kill_info {
int num_width; int num_width;
int name_width; int name_width;
}; };
static char *kill_fmt_entry(void *arg, int i, char *buf, int buflen); static char *kill_fmt_entry(const void *, int, char *, int);
/* format a single kill item */ /* format a single kill item */
static char * static char *
kill_fmt_entry(void *arg, int i, char *buf, int buflen) kill_fmt_entry(const void *arg, int i, char *buf, int buflen)
{ {
struct kill_info *ki = (struct kill_info *) arg; const struct kill_info *ki = (const struct kill_info *)arg;
i++; i++;
if (sigtraps[i].name) if (sigtraps[i].name)
@ -1538,7 +1537,8 @@ c_umask(char **wp)
int int
c_dot(char **wp) c_dot(char **wp)
{ {
char *file, *cp; const char *file;
char *cp;
char **argv; char **argv;
int argc; int argc;
int i; int i;
@ -1965,8 +1965,9 @@ c_set(char **wp)
char **owp = wp; char **owp = wp;
if (wp[1] == NULL) { if (wp[1] == NULL) {
static const char *const args [] = { "set", "-", NULL }; static char args0[] = "set", args1[] = "-",
return c_typeset((char **) args); *args[] = { args0, args1, NULL };
return c_typeset(args);
} }
argi = parse_args(wp, OF_SET, &setargs); argi = parse_args(wp, OF_SET, &setargs);

13
main.c
View File

@ -13,7 +13,7 @@
#include <locale.h> #include <locale.h>
#endif #endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.60 2006/11/12 10:44:41 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/main.c,v 1.61 2006/11/12 14:58:15 tg Exp $");
extern char **environ; extern char **environ;
@ -77,11 +77,10 @@ main(int argc, char *argv[])
/* make sure argv[] is sane */ /* make sure argv[] is sane */
if (!*argv) { if (!*argv) {
static const char *empty_argv[] = { static char empty_argv0[] = "mksh",
"mksh", NULL *empty_argv[] = { empty_argv0, NULL };
};
argv = (char **)empty_argv; argv = empty_argv;
argc = 1; argc = 1;
} }
kshname = *argv; kshname = *argv;
@ -1239,8 +1238,8 @@ ktnext(struct tstate *ts)
static int static int
tnamecmp(const void *p1, const void *p2) tnamecmp(const void *p1, const void *p2)
{ {
const struct tbl *a = *((const struct tbl **)p1); const struct tbl *a = *((struct tbl * const *)p1);
const struct tbl *b = *((const struct tbl **)p2); const struct tbl *b = *((struct tbl * const *)p2);
return (strcmp(a->name, b->name)); return (strcmp(a->name, b->name));
} }

17
misc.c
View File

@ -6,7 +6,7 @@
#include <grp.h> #include <grp.h>
#endif #endif
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.41 2006/11/12 13:35:29 tg Exp $\t" __RCSID("$MirOS: src/bin/mksh/misc.c,v 1.42 2006/11/12 14:58:15 tg Exp $\t"
MKSH_SH_H_ID); MKSH_SH_H_ID);
#undef USE_CHVT #undef USE_CHVT
@ -160,14 +160,14 @@ struct options_info {
int opts[NELEM(options)]; int opts[NELEM(options)];
}; };
static char *options_fmt_entry(void *arg, int i, char *buf, int buflen); static char *options_fmt_entry(const void *arg, int, char *, int);
static void printoptions(int verbose); static void printoptions(int);
/* format a single select menu item */ /* format a single select menu item */
static char * static char *
options_fmt_entry(void *arg, int i, char *buf, int buflen) options_fmt_entry(const void *arg, int i, char *buf, int buflen)
{ {
struct options_info *oi = (struct options_info *) arg; const struct options_info *oi = (const struct options_info *)arg;
shf_snprintf(buf, buflen, "%-*s %s", shf_snprintf(buf, buflen, "%-*s %s",
oi->opt_width, options[oi->opts[i]].name, oi->opt_width, options[oi->opts[i]].name,
@ -764,7 +764,7 @@ pat_scan(const unsigned char *p, const unsigned char *pe, int match_sep)
int int
xstrcmp(const void *p1, const void *p2) xstrcmp(const void *p1, const void *p2)
{ {
return (strcmp(*(const char **)p1, *(const char **)p2)); return (strcmp(*(char * const *)p1, *(char * const *)p2));
} }
/* Initialise a Getopt structure */ /* Initialise a Getopt structure */
@ -936,8 +936,9 @@ print_value_quoted(const char *s)
* element * element
*/ */
void void
print_columns(struct shf *shf, int n, char *(*func) (void *, int, char *, int), print_columns(struct shf *shf, int n,
void *arg, int max_width, int prefcol) char *(*func) (const void *, int, char *, int),
const void *arg, int max_width, int prefcol)
{ {
char *str = (char *) alloc(max_width + 1, ATEMP); char *str = (char *) alloc(max_width + 1, ATEMP);
int i; int i;

17
sh.h
View File

@ -8,7 +8,7 @@
/* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */ /* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */
/* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */ /* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.82 2006/11/12 13:15:26 tg Exp $" #define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.83 2006/11/12 14:58:15 tg Exp $"
#define MKSH_VERSION "R29 2006/11/12" #define MKSH_VERSION "R29 2006/11/12"
#if HAVE_SYS_PARAM_H #if HAVE_SYS_PARAM_H
@ -576,7 +576,7 @@ struct tbl { /* table item */
} u2; } u2;
union { union {
struct tbl *array; /* array values */ struct tbl *array; /* array values */
char *fpath; /* temporary path to undef function */ const char *fpath; /* temporary path to undef function */
} u; } u;
char name[4]; /* name -- variable length */ char name[4]; /* name -- variable length */
}; };
@ -1086,7 +1086,7 @@ int define(const char *, struct op *);
void builtin(const char *, int (*)(char **)); void builtin(const char *, int (*)(char **));
struct tbl *findcom(const char *, int); struct tbl *findcom(const char *, int);
void flushcom(int); void flushcom(int);
char *search(const char *, const char *, int, int *); const char *search(const char *, const char *, int, int *);
int search_access(const char *, int, int *); int search_access(const char *, int, int *);
int pr_menu(char *const *); int pr_menu(char *const *);
int pr_list(char *const *); int pr_list(char *const *);
@ -1252,8 +1252,9 @@ int xstrcmp(const void *, const void *);
void ksh_getopt_reset(Getopt *, int); void ksh_getopt_reset(Getopt *, int);
int ksh_getopt(char **, Getopt *, const char *); int ksh_getopt(char **, Getopt *, const char *);
void print_value_quoted(const char *); void print_value_quoted(const char *);
void print_columns(struct shf *, int, char *(*)(void *, int, char *, int), void print_columns(struct shf *, int,
void *, int, int prefcol); char *(*)(const void *, int, char *, int),
const void *, int, int prefcol);
void strip_nuls(char *, int); void strip_nuls(char *, int);
int blocking_read(int, char *, int); int blocking_read(int, char *, int);
int reset_nonblock(int); int reset_nonblock(int);
@ -1295,7 +1296,7 @@ int fptreef(struct shf *, int, const char *, ...);
char *snptreef(char *, int, const char *, ...); char *snptreef(char *, int, const char *, ...);
struct op *tcopy(struct op *, Area *); struct op *tcopy(struct op *, Area *);
char *wdcopy(const char *, Area *); char *wdcopy(const char *, Area *);
char *wdscan(const char *, int); const char *wdscan(const char *, int);
char *wdstrip(const char *); char *wdstrip(const char *);
void tfree(struct op *, Area *); void tfree(struct op *, Area *);
/* var.c */ /* var.c */
@ -1312,8 +1313,8 @@ void setint(struct tbl *, long);
int getint(struct tbl *, long *, bool); int getint(struct tbl *, long *, bool);
struct tbl *typeset(const char *, Tflag, Tflag, int, int); struct tbl *typeset(const char *, Tflag, Tflag, int, int);
void unset(struct tbl *, int); void unset(struct tbl *, int);
char *skip_varname(const char *, int); const char *skip_varname(const char *, int);
char *skip_wdvarname(const char *, int); const char *skip_wdvarname(const char *, int);
int is_wdvarname(const char *, int); int is_wdvarname(const char *, int);
int is_wdvarassign(const char *); int is_wdvarassign(const char *);
char **makenv(void); char **makenv(void);

10
tree.c
View File

@ -2,7 +2,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.6 2006/11/10 00:09:27 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/tree.c,v 1.7 2006/11/12 14:58:16 tg Exp $");
#define INDENT 4 #define INDENT 4
@ -477,7 +477,7 @@ wdcopy(const char *wp, Area *ap)
} }
/* return the position of prefix c in wp plus 1 */ /* return the position of prefix c in wp plus 1 */
char * const char *
wdscan(const char *wp, int c) wdscan(const char *wp, int c)
{ {
int nest = 0; int nest = 0;
@ -485,7 +485,7 @@ wdscan(const char *wp, int c)
while (1) while (1)
switch (*wp++) { switch (*wp++) {
case EOS: case EOS:
return (char *) wp; return (wp);
case CHAR: case CHAR:
case QCHAR: case QCHAR:
wp++; wp++;
@ -506,7 +506,7 @@ wdscan(const char *wp, int c)
case CSUBST: case CSUBST:
wp++; wp++;
if (c == CSUBST && nest == 0) if (c == CSUBST && nest == 0)
return (char *) wp; return (wp);
nest--; nest--;
break; break;
case OPAT: case OPAT:
@ -516,7 +516,7 @@ wdscan(const char *wp, int c)
case SPAT: case SPAT:
case CPAT: case CPAT:
if (c == wp[-1] && nest == 0) if (c == wp[-1] && nest == 0)
return (char *) wp; return (wp);
if (wp[-1] == CPAT) if (wp[-1] == CPAT)
nest--; nest--;
break; break;

23
var.c
View File

@ -2,7 +2,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.31 2006/11/10 07:52:04 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/var.c,v 1.32 2006/11/12 14:58:16 tg Exp $");
/* /*
* Variables * Variables
@ -32,14 +32,14 @@ void
newblock(void) newblock(void)
{ {
struct block *l; struct block *l;
static char *const empty[] = {null}; static char *empty[] = {null};
l = (struct block *) alloc(sizeof(struct block), ATEMP); l = (struct block *) alloc(sizeof(struct block), ATEMP);
l->flags = 0; l->flags = 0;
ainit(&l->area); /* todo: could use e->area (l->area => l->areap) */ ainit(&l->area); /* todo: could use e->area (l->area => l->areap) */
if (!e->loc) { if (!e->loc) {
l->argc = 0; l->argc = 0;
l->argv = (char **) empty; l->argv = empty;
} else { } else {
l->argc = e->loc->argc; l->argc = e->loc->argc;
l->argv = e->loc->argv; l->argv = e->loc->argv;
@ -606,7 +606,7 @@ typeset(const char *var, Tflag set, Tflag clr, int field, int base)
/* Importing from original environment: must have an = */ /* Importing from original environment: must have an = */
if (set & IMPORT) if (set & IMPORT)
return NULL; return NULL;
tvar = (char *) var; tvar = str_save(var, ATEMP);
val = NULL; val = NULL;
} }
@ -628,7 +628,6 @@ typeset(const char *var, Tflag set, Tflag clr, int field, int base)
(val || clr || (set & ~EXPORT))) (val || clr || (set & ~EXPORT)))
/* XXX check calls - is error here ok by POSIX? */ /* XXX check calls - is error here ok by POSIX? */
errorf("%s: is read only", tvar); errorf("%s: is read only", tvar);
if (val)
afree(tvar, ATEMP); afree(tvar, ATEMP);
/* most calls are with set/clr == 0 */ /* most calls are with set/clr == 0 */
@ -745,7 +744,7 @@ unset(struct tbl *vp, int array_ref)
* argument if there is no legal name, returns * a pointer to the terminating * argument if there is no legal name, returns * a pointer to the terminating
* null if whole string is legal). * null if whole string is legal).
*/ */
char * const char *
skip_varname(const char *s, int aok) skip_varname(const char *s, int aok)
{ {
int alen; int alen;
@ -756,11 +755,11 @@ skip_varname(const char *s, int aok)
if (aok && *s == '[' && (alen = array_ref_len(s))) if (aok && *s == '[' && (alen = array_ref_len(s)))
s += alen; s += alen;
} }
return (char *) s; return (s);
} }
/* Return a pointer to the first character past any legal variable name. */ /* Return a pointer to the first character past any legal variable name. */
char * const char *
skip_wdvarname(const char *s, skip_wdvarname(const char *s,
int aok) /* skip array de-reference? */ int aok) /* skip array de-reference? */
{ {
@ -788,14 +787,14 @@ skip_wdvarname(const char *s,
} }
} }
} }
return (char *) s; return (s);
} }
/* Check if coded string s is a variable name */ /* Check if coded string s is a variable name */
int int
is_wdvarname(const char *s, int aok) is_wdvarname(const char *s, int aok)
{ {
char *p = skip_wdvarname(s, aok); const char *p = skip_wdvarname(s, aok);
return p != s && p[0] == EOS; return p != s && p[0] == EOS;
} }
@ -804,7 +803,7 @@ is_wdvarname(const char *s, int aok)
int int
is_wdvarassign(const char *s) is_wdvarassign(const char *s)
{ {
char *p = skip_wdvarname(s, true); const char *p = skip_wdvarname(s, true);
return p != s && p[0] == CHAR && p[1] == '='; return p != s && p[0] == CHAR && p[1] == '=';
} }
@ -1144,7 +1143,7 @@ arrayname(const char *str)
if ((p = strchr(str, '[')) == 0) if ((p = strchr(str, '[')) == 0)
/* Shouldn't happen, but why worry? */ /* Shouldn't happen, but why worry? */
return (char *) str; return str_save(str, ATEMP);
return str_nsave(str, p - str, ATEMP); return str_nsave(str, p - str, ATEMP);
} }