* revert some of the const-warning cleanup which must be done

with different means (reads, tricky magical kludgery)
  YES, THIS BREAKS -rHEAD, I KNOW.
* while here, fix spelling
This commit is contained in:
tg 2007-01-12 10:18:22 +00:00
parent 03e8f0ec83
commit 87f681b488
10 changed files with 48 additions and 50 deletions

View File

@ -1,5 +1,5 @@
#!/usr/bin/perl #!/usr/bin/perl
# $MirOS: src/bin/mksh/check.pl,v 1.8 2006/05/08 11:59:41 tg Exp $ # $MirOS: src/bin/mksh/check.pl,v 1.9 2007/01/12 10:18:19 tg Exp $
# $OpenBSD: th,v 1.12 2005/05/28 04:53:47 millert Exp $ # $OpenBSD: th,v 1.12 2005/05/28 04:53:47 millert Exp $
#- #-
# Example test: # Example test:
@ -843,14 +843,14 @@ read_test
last if /^\s*---\s*$/; last if /^\s*---\s*$/;
$start_lineno = $. if !defined $start_lineno; $start_lineno = $. if !defined $start_lineno;
if (!/^([-\w]+):\s*(|\S|\S.*\S)\s*$/) { if (!/^([-\w]+):\s*(|\S|\S.*\S)\s*$/) {
print STDERR "$prog:$file:$.: unrecognized line\n"; print STDERR "$prog:$file:$.: unrecognised line\n";
return undef; return undef;
} }
($field, $val) = ($1, $2); ($field, $val) = ($1, $2);
$sfield = $field; $sfield = $field;
$flags = $test_fields{$field}; $flags = $test_fields{$field};
if (!defined $flags) { if (!defined $flags) {
print STDERR "$prog:$file:$.: unrecognized field \"$field\"\n"; print STDERR "$prog:$file:$.: unrecognised field \"$field\"\n";
return undef; return undef;
} }
if ($flags =~ /s/) { if ($flags =~ /s/) {

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.81 2007/01/12 00:25:39 tg Exp $ # $MirOS: src/bin/mksh/check.t,v 1.82 2007/01/12 10:18:19 tg Exp $
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $ # $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
@ -2226,7 +2226,7 @@ description:
(ksh88 fails this test - shell exits, even with -i) (ksh88 fails this test - shell exits, even with -i)
arguments: !-i! arguments: !-i!
stdin: stdin:
PS1= # minimize prompt hassles PS1= # minimise prompt hassles
typeset -i4 a=10 typeset -i4 a=10
typeset -i a=2+ typeset -i a=2+
echo $a echo $a
@ -3059,7 +3059,7 @@ expected-stdout:
--- ---
name: regression-45 name: regression-45
description: description:
Parameter assignments with [] recognized correctly Parameter assignments with [] recognised correctly
stdin: stdin:
FOO=*[12] FOO=*[12]
BAR=abc[ BAR=abc[
@ -3366,7 +3366,7 @@ expected-stdout:
name: regression-57 name: regression-57
description: description:
Check if typeset output is correct for Check if typeset output is correct for
uninitialized array elements. uninitialised array elements.
stdin: stdin:
typeset -i xxx[4] typeset -i xxx[4]
echo A echo A

14
edit.c
View File

@ -5,7 +5,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.75 2007/01/12 01:49:27 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/edit.c,v 1.76 2007/01/12 10:18:20 tg Exp $");
/* tty driver characters we are interested in */ /* tty driver characters we are interested in */
typedef struct { typedef struct {
@ -1197,7 +1197,7 @@ static void bind_if_not_bound(int, int, int);
#define XFUNC_yank 45 #define XFUNC_yank 45
#define XFUNC_comp_list 46 #define XFUNC_comp_list 46
#define XFUNC_expand 47 #define XFUNC_expand 47
#define XFUNC_fold_capitalize 48 #define XFUNC_fold_capitalise 48
#define XFUNC_fold_lower 49 #define XFUNC_fold_lower 49
#define XFUNC_fold_upper 50 #define XFUNC_fold_upper 50
#define XFUNC_set_arg 51 #define XFUNC_set_arg 51
@ -1254,7 +1254,7 @@ static int x_xchg_point_mark (int);
static int x_yank (int); static int x_yank (int);
static int x_comp_list (int); static int x_comp_list (int);
static int x_expand (int); static int x_expand (int);
static int x_fold_capitalize (int); static int x_fold_capitalise (int);
static int x_fold_lower (int); static int x_fold_lower (int);
static int x_fold_upper (int); static int x_fold_upper (int);
static int x_set_arg (int); static int x_set_arg (int);
@ -1310,7 +1310,7 @@ static const struct x_ftab x_ftab[] = {
{ x_yank, "yank", 0 }, { x_yank, "yank", 0 },
{ x_comp_list, "complete-list", 0 }, { x_comp_list, "complete-list", 0 },
{ x_expand, "expand-file", 0 }, { x_expand, "expand-file", 0 },
{ x_fold_capitalize, "capitalize-word", XF_ARG }, { x_fold_capitalise, "capitalize-word", XF_ARG },
{ x_fold_lower, "downcase-word", XF_ARG }, { x_fold_lower, "downcase-word", XF_ARG },
{ x_fold_upper, "upcase-word", XF_ARG }, { x_fold_upper, "upcase-word", XF_ARG },
{ x_set_arg, "set-arg", XF_NOBIND }, { x_set_arg, "set-arg", XF_NOBIND },
@ -1385,8 +1385,8 @@ static struct x_defbindings const x_defbindings[] = {
{ XFUNC_fold_upper, 1, 'u' }, { XFUNC_fold_upper, 1, 'u' },
{ XFUNC_fold_lower, 1, 'L' }, { XFUNC_fold_lower, 1, 'L' },
{ XFUNC_fold_lower, 1, 'l' }, { XFUNC_fold_lower, 1, 'l' },
{ XFUNC_fold_capitalize, 1, 'C' }, { XFUNC_fold_capitalise, 1, 'C' },
{ XFUNC_fold_capitalize, 1, 'c' }, { XFUNC_fold_capitalise, 1, 'c' },
/* These for ansi arrow keys: arguablely shouldn't be here by /* These for ansi arrow keys: arguablely shouldn't be here by
* default, but its simpler/faster/smaller than using termcap * default, but its simpler/faster/smaller than using termcap
* entries. * entries.
@ -3163,7 +3163,7 @@ x_fold_lower(int c __unused)
/* Lowercase N(1) words */ /* Lowercase N(1) words */
static int static int
x_fold_capitalize(int c __unused) x_fold_capitalise(int c __unused)
{ {
return x_fold_case('C'); return x_fold_case('C');
} }

19
exec.c
View File

@ -2,11 +2,11 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.21 2007/01/12 01:49:27 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/exec.c,v 1.22 2007/01/12 10:18:20 tg Exp $");
static int comexec(struct op *, struct tbl *volatile, char **, static int comexec(struct op *, struct tbl *volatile, char **,
int volatile); int volatile);
static void scriptexec(struct op *, char **) __dead; static __dead void scriptexec(struct op *, char **);
static int call_builtin(struct tbl *, char **); static int call_builtin(struct tbl *, char **);
static int iosetup(struct ioword *, struct tbl *); static int iosetup(struct ioword *, struct tbl *);
static int herein(const char *, int); static int herein(const char *, int);
@ -81,7 +81,7 @@ execute(struct op *volatile t,
if (t->ioact != NULL || t->type == TPIPE || t->type == TCOPROC) { if (t->ioact != NULL || t->type == TPIPE || t->type == TCOPROC) {
e->savefd = (short *) alloc(sizeofN(short, NUFILE), ATEMP); e->savefd = (short *) alloc(sizeofN(short, NUFILE), ATEMP);
/* initialize to not redirected */ /* initialise to not redirected */
memset(e->savefd, 0, sizeofN(short, NUFILE)); memset(e->savefd, 0, sizeofN(short, NUFILE));
} }
@ -206,7 +206,7 @@ execute(struct op *volatile t,
case TASYNC: case TASYNC:
/* XXX non-optimal, I think - "(foo &)", forks for (), /* XXX non-optimal, I think - "(foo &)", forks for (),
* forks again for async... parent should optimize * forks again for async... parent should optimise
* this to "foo &"... * this to "foo &"...
*/ */
rv = execute(t->left, (flags&~XEXEC)|XBGND|XFORK); rv = execute(t->left, (flags&~XEXEC)|XBGND|XFORK);
@ -665,17 +665,16 @@ comexec(struct op *t, struct tbl *volatile tp, char **ap, volatile int flags)
static void static void
scriptexec(struct op *tp, char **ap) scriptexec(struct op *tp, char **ap)
{ {
static char execshell[] = "/bin/sh";
const char *sh; const char *sh;
sh = str_val(global("EXECSHELL")); sh = str_val(global("EXECSHELL"));
if (sh && *sh) if (sh && *sh)
sh = search(sh, path, X_OK, NULL); sh = search(sh, path, X_OK, NULL);
if (!sh || !*sh) if (!sh || !*sh)
sh = execshell; sh = "/bin/sh";
*tp->args-- = tp->str; *tp->args-- = tp->str;
*tp->args = str_save(sh, ATEMP); *tp->args = sh;
execve(tp->args[0], tp->args, ap); execve(tp->args[0], tp->args, ap);
@ -1195,10 +1194,8 @@ 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 char read_args0[] = "read", static const char *const read_args[] = {
read_args1[] = "-r", read_args2[] = "REPLY", "read", "-r", "REPLY", NULL
*read_args[] = {
read_args0, read_args1, read_args2, NULL
}; };
char *s; char *s;
int i, argct; int i, argct;

14
funcs.c
View File

@ -5,7 +5,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.42 2007/01/12 01:49:28 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.43 2007/01/12 10:18:20 tg Exp $");
int int
c_cd(char **wp) c_cd(char **wp)
@ -206,10 +206,10 @@ c_print(char **wp)
/* A compromise between sysV and BSD echo commands: /* A compromise between sysV and BSD echo commands:
* escape sequences are enabled by default, and * escape sequences are enabled by default, and
* -n, -e and -E are recognized if they appear * -n, -e and -E are recognised if they appear
* in arguments with no illegal options (ie, echo -nq * in arguments with no illegal options (ie, echo -nq
* will print -nq). * will print -nq).
* Different from sysV echo since options are recognized, * Different from sysV echo since options are recognised,
* different from BSD echo since escape sequences are enabled * different from BSD echo since escape sequences are enabled
* by default. * by default.
*/ */
@ -856,8 +856,9 @@ 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 char args0[] = "unalias", args1[] = "-ta", static const char *const args[] = {
*args[] = { args0, args1, NULL }; "unalias", "-ta", 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"
@ -1963,8 +1964,7 @@ c_set(char **wp)
char **owp = wp; char **owp = wp;
if (wp[1] == NULL) { if (wp[1] == NULL) {
static char args0[] = "set", args1[] = "-", static const char *const args [] = { "set", "-", NULL };
*args[] = { args0, args1, NULL };
return c_typeset(args); return c_typeset(args);
} }

4
jobs.c
View File

@ -2,7 +2,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.17 2007/01/12 01:49:28 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.18 2007/01/12 10:18:21 tg Exp $");
/* Order important! */ /* Order important! */
#define PRUNNING 0 #define PRUNNING 0
@ -119,7 +119,7 @@ static void put_job(Job *, int);
static void remove_job(Job *, const char *); static void remove_job(Job *, const char *);
static int kill_job(Job *, int); static int kill_job(Job *, int);
/* initialize job control */ /* initialise job control */
void void
j_init(int mflagset) j_init(int mflagset)
{ {

6
lex.c
View File

@ -2,7 +2,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.24 2006/11/10 07:52:03 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/lex.c,v 1.25 2007/01/12 10:18:21 tg Exp $");
/* Structure to keep track of the lexing state and the various pieces of info /* Structure to keep track of the lexing state and the various pieces of info
* needed for each particular state. */ * needed for each particular state. */
@ -63,10 +63,10 @@ static int dopprompt(const char *, int, int);
static int backslash_skip; static int backslash_skip;
static int ignore_backslash_newline; static int ignore_backslash_newline;
/* optimized getsc_bn() */ /* optimised getsc_bn() */
#define getsc() (*source->str != '\0' && *source->str != '\\' \ #define getsc() (*source->str != '\0' && *source->str != '\\' \
&& !backslash_skip ? *source->str++ : getsc_bn()) && !backslash_skip ? *source->str++ : getsc_bn())
/* optimized getsc__() */ /* optimised getsc__() */
#define getsc_() ((*source->str != '\0') ? *source->str++ : getsc__()) #define getsc_() ((*source->str != '\0') ? *source->str++ : getsc__())
#define STATE_BSIZE 32 #define STATE_BSIZE 32

15
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.66 2007/01/12 02:06:34 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/main.c,v 1.67 2007/01/12 10:18:21 tg Exp $");
extern char **environ; extern char **environ;
@ -82,15 +82,16 @@ main(int argc, char *argv[])
/* make sure argv[] is sane */ /* make sure argv[] is sane */
if (!*argv) { if (!*argv) {
static char empty_argv0[] = "mksh", static const char *empty_argv[] = {
*empty_argv[] = { empty_argv0, NULL }; "mksh", NULL
};
argv = empty_argv; argv = empty_argv;
argc = 1; argc = 1;
} }
kshname = *argv; kshname = *argv;
ainit(&aperm); /* initialize permanent Area */ ainit(&aperm); /* initialise permanent Area */
/* set up base environment */ /* set up base environment */
memset(&env, 0, sizeof(env)); memset(&env, 0, sizeof(env));
@ -274,11 +275,11 @@ main(int argc, char *argv[])
Flag(FTALKING)) Flag(FTALKING))
reset_nonblock(0); reset_nonblock(0);
/* initialize job control */ /* initialise job control */
i = Flag(FMONITOR) != 127; i = Flag(FMONITOR) != 127;
Flag(FMONITOR) = 0; Flag(FMONITOR) = 0;
j_init(i); j_init(i);
/* Do this after j_init(), as tty_fd is not initialized 'til then */ /* Do this after j_init(), as tty_fd is not initialised 'til then */
if (Flag(FTALKING)) { if (Flag(FTALKING)) {
#if HAVE_SETLOCALE_CTYPE #if HAVE_SETLOCALE_CTYPE
#define isuc(x) (((x) != NULL) && \ #define isuc(x) (((x) != NULL) && \
@ -691,7 +692,7 @@ remove_temps(struct temp *tp)
} }
} }
/* Initialize tty_fd. Used for saving/reseting tty modes upon /* Initialise tty_fd. Used for saving/reseting tty modes upon
* foreground job completion and for setting up tty process group. * foreground job completion and for setting up tty process group.
*/ */
void void

8
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.95 2007/01/12 02:02:21 tg Exp $" #define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.96 2007/01/12 10:18:21 tg Exp $"
#define MKSH_VERSION "R29 2007/01/12" #define MKSH_VERSION "R29 2007/01/12"
#if HAVE_SYS_PARAM_H #if HAVE_SYS_PARAM_H
@ -882,7 +882,7 @@ typedef struct XString {
typedef char *XStringP; typedef char *XStringP;
/* initialize expandable string */ /* initialise expandable string */
#define Xinit(xs, xp, length, area) do { \ #define Xinit(xs, xp, length, area) do { \
(xs).len = length; \ (xs).len = length; \
(xs).areap = (area); \ (xs).areap = (area); \
@ -1053,8 +1053,8 @@ typedef union {
/* flags to yylex */ /* flags to yylex */
#define CONTIN BIT(0) /* skip new lines to complete command */ #define CONTIN BIT(0) /* skip new lines to complete command */
#define ONEWORD BIT(1) /* single word for substitute() */ #define ONEWORD BIT(1) /* single word for substitute() */
#define ALIAS BIT(2) /* recognize alias */ #define ALIAS BIT(2) /* recognise alias */
#define KEYWORD BIT(3) /* recognize keywords */ #define KEYWORD BIT(3) /* recognise keywords */
#define LETEXPR BIT(4) /* get expression inside (( )) */ #define LETEXPR BIT(4) /* get expression inside (( )) */
#define VARASN BIT(5) /* check for var=word */ #define VARASN BIT(5) /* check for var=word */
#define ARRAYVAR BIT(6) /* parse x[1 & 2] as one word */ #define ARRAYVAR BIT(6) /* parse x[1 & 2] as one word */

4
shf.c
View File

@ -2,7 +2,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.8 2006/11/10 07:52:04 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/shf.c,v 1.9 2007/01/12 10:18:22 tg Exp $");
/* flags to shf_emptybuf() */ /* flags to shf_emptybuf() */
#define EB_READSW 0x01 /* about to switch to reading */ #define EB_READSW 0x01 /* about to switch to reading */
@ -715,7 +715,7 @@ shf_smprintf(const char *fmt, ...)
*/ */
/* /*
* What kinda of machine we on? Hopefully the C compiler will optimize * What kinda of machine we on? Hopefully the C compiler will optimise
* this out... * this out...
* *
* For shorts, we want sign extend for %d but not for %[oxu] - on 16 bit * For shorts, we want sign extend for %d but not for %[oxu] - on 16 bit