From 87f681b48813b7beba1f611a995a6b59ffb15d77 Mon Sep 17 00:00:00 2001 From: tg Date: Fri, 12 Jan 2007 10:18:22 +0000 Subject: [PATCH] * 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 --- check.pl | 6 +++--- check.t | 8 ++++---- edit.c | 14 +++++++------- exec.c | 19 ++++++++----------- funcs.c | 14 +++++++------- jobs.c | 4 ++-- lex.c | 6 +++--- main.c | 15 ++++++++------- sh.h | 8 ++++---- shf.c | 4 ++-- 10 files changed, 48 insertions(+), 50 deletions(-) diff --git a/check.pl b/check.pl index 83a7bcc..810a35f 100644 --- a/check.pl +++ b/check.pl @@ -1,5 +1,5 @@ #!/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 $ #- # Example test: @@ -843,14 +843,14 @@ read_test last if /^\s*---\s*$/; $start_lineno = $. if !defined $start_lineno; if (!/^([-\w]+):\s*(|\S|\S.*\S)\s*$/) { - print STDERR "$prog:$file:$.: unrecognized line\n"; + print STDERR "$prog:$file:$.: unrecognised line\n"; return undef; } ($field, $val) = ($1, $2); $sfield = $field; $flags = $test_fields{$field}; if (!defined $flags) { - print STDERR "$prog:$file:$.: unrecognized field \"$field\"\n"; + print STDERR "$prog:$file:$.: unrecognised field \"$field\"\n"; return undef; } if ($flags =~ /s/) { diff --git a/check.t b/check.t index 4ddd8e2..01768fd 100644 --- a/check.t +++ b/check.t @@ -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: 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 $ @@ -2226,7 +2226,7 @@ description: (ksh88 fails this test - shell exits, even with -i) arguments: !-i! stdin: - PS1= # minimize prompt hassles + PS1= # minimise prompt hassles typeset -i4 a=10 typeset -i a=2+ echo $a @@ -3059,7 +3059,7 @@ expected-stdout: --- name: regression-45 description: - Parameter assignments with [] recognized correctly + Parameter assignments with [] recognised correctly stdin: FOO=*[12] BAR=abc[ @@ -3366,7 +3366,7 @@ expected-stdout: name: regression-57 description: Check if typeset output is correct for - uninitialized array elements. + uninitialised array elements. stdin: typeset -i xxx[4] echo A diff --git a/edit.c b/edit.c index ea188d7..65ec1f6 100644 --- a/edit.c +++ b/edit.c @@ -5,7 +5,7 @@ #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 */ typedef struct { @@ -1197,7 +1197,7 @@ static void bind_if_not_bound(int, int, int); #define XFUNC_yank 45 #define XFUNC_comp_list 46 #define XFUNC_expand 47 -#define XFUNC_fold_capitalize 48 +#define XFUNC_fold_capitalise 48 #define XFUNC_fold_lower 49 #define XFUNC_fold_upper 50 #define XFUNC_set_arg 51 @@ -1254,7 +1254,7 @@ static int x_xchg_point_mark (int); static int x_yank (int); static int x_comp_list (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_upper (int); static int x_set_arg (int); @@ -1310,7 +1310,7 @@ static const struct x_ftab x_ftab[] = { { x_yank, "yank", 0 }, { x_comp_list, "complete-list", 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_upper, "upcase-word", XF_ARG }, { 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_lower, 1, 'L' }, { XFUNC_fold_lower, 1, 'l' }, - { XFUNC_fold_capitalize, 1, 'C' }, - { XFUNC_fold_capitalize, 1, 'c' }, + { XFUNC_fold_capitalise, 1, 'C' }, + { XFUNC_fold_capitalise, 1, 'c' }, /* These for ansi arrow keys: arguablely shouldn't be here by * default, but its simpler/faster/smaller than using termcap * entries. @@ -3163,7 +3163,7 @@ x_fold_lower(int c __unused) /* Lowercase N(1) words */ static int -x_fold_capitalize(int c __unused) +x_fold_capitalise(int c __unused) { return x_fold_case('C'); } diff --git a/exec.c b/exec.c index ae7debc..d749831 100644 --- a/exec.c +++ b/exec.c @@ -2,11 +2,11 @@ #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 **, 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 iosetup(struct ioword *, struct tbl *); 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) { e->savefd = (short *) alloc(sizeofN(short, NUFILE), ATEMP); - /* initialize to not redirected */ + /* initialise to not redirected */ memset(e->savefd, 0, sizeofN(short, NUFILE)); } @@ -206,7 +206,7 @@ execute(struct op *volatile t, case TASYNC: /* 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 &"... */ 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 scriptexec(struct op *tp, char **ap) { - static char execshell[] = "/bin/sh"; const char *sh; sh = str_val(global("EXECSHELL")); if (sh && *sh) sh = search(sh, path, X_OK, NULL); if (!sh || !*sh) - sh = execshell; + sh = "/bin/sh"; *tp->args-- = tp->str; - *tp->args = str_save(sh, ATEMP); + *tp->args = sh; execve(tp->args[0], tp->args, ap); @@ -1195,10 +1194,8 @@ herein(const char *content, int sub) static char * do_selectargs(char **ap, bool print_menu) { - static char read_args0[] = "read", - read_args1[] = "-r", read_args2[] = "REPLY", - *read_args[] = { - read_args0, read_args1, read_args2, NULL + static const char *const read_args[] = { + "read", "-r", "REPLY", NULL }; char *s; int i, argct; diff --git a/funcs.c b/funcs.c index 107d373..4885986 100644 --- a/funcs.c +++ b/funcs.c @@ -5,7 +5,7 @@ #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 c_cd(char **wp) @@ -206,10 +206,10 @@ c_print(char **wp) /* A compromise between sysV and BSD echo commands: * 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 * 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 * by default. */ @@ -856,8 +856,9 @@ c_alias(char **wp) /* "hash -r" means reset all the tracked aliases.. */ if (rflag) { - static char args0[] = "unalias", args1[] = "-ta", - *args[] = { args0, args1, NULL }; + static const char *const args[] = { + "unalias", "-ta", NULL + }; if (!tflag || *wp) { shprintf("alias: -r flag can only be used with -t" @@ -1963,8 +1964,7 @@ c_set(char **wp) char **owp = wp; if (wp[1] == NULL) { - static char args0[] = "set", args1[] = "-", - *args[] = { args0, args1, NULL }; + static const char *const args [] = { "set", "-", NULL }; return c_typeset(args); } diff --git a/jobs.c b/jobs.c index 75e781a..3f6f088 100644 --- a/jobs.c +++ b/jobs.c @@ -2,7 +2,7 @@ #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! */ #define PRUNNING 0 @@ -119,7 +119,7 @@ static void put_job(Job *, int); static void remove_job(Job *, const char *); static int kill_job(Job *, int); -/* initialize job control */ +/* initialise job control */ void j_init(int mflagset) { diff --git a/lex.c b/lex.c index f309696..4ed680d 100644 --- a/lex.c +++ b/lex.c @@ -2,7 +2,7 @@ #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 * needed for each particular state. */ @@ -63,10 +63,10 @@ static int dopprompt(const char *, int, int); static int backslash_skip; static int ignore_backslash_newline; -/* optimized getsc_bn() */ +/* optimised getsc_bn() */ #define getsc() (*source->str != '\0' && *source->str != '\\' \ && !backslash_skip ? *source->str++ : getsc_bn()) -/* optimized getsc__() */ +/* optimised getsc__() */ #define getsc_() ((*source->str != '\0') ? *source->str++ : getsc__()) #define STATE_BSIZE 32 diff --git a/main.c b/main.c index 8246711..76aab81 100644 --- a/main.c +++ b/main.c @@ -13,7 +13,7 @@ #include #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; @@ -82,15 +82,16 @@ main(int argc, char *argv[]) /* make sure argv[] is sane */ if (!*argv) { - static char empty_argv0[] = "mksh", - *empty_argv[] = { empty_argv0, NULL }; + static const char *empty_argv[] = { + "mksh", NULL + }; argv = empty_argv; argc = 1; } kshname = *argv; - ainit(&aperm); /* initialize permanent Area */ + ainit(&aperm); /* initialise permanent Area */ /* set up base environment */ memset(&env, 0, sizeof(env)); @@ -274,11 +275,11 @@ main(int argc, char *argv[]) Flag(FTALKING)) reset_nonblock(0); - /* initialize job control */ + /* initialise job control */ i = Flag(FMONITOR) != 127; Flag(FMONITOR) = 0; 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 HAVE_SETLOCALE_CTYPE #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. */ void diff --git a/sh.h b/sh.h index 8ccbe95..b712ff3 100644 --- a/sh.h +++ b/sh.h @@ -8,7 +8,7 @@ /* $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 $ */ -#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" #if HAVE_SYS_PARAM_H @@ -882,7 +882,7 @@ typedef struct XString { typedef char *XStringP; -/* initialize expandable string */ +/* initialise expandable string */ #define Xinit(xs, xp, length, area) do { \ (xs).len = length; \ (xs).areap = (area); \ @@ -1053,8 +1053,8 @@ typedef union { /* flags to yylex */ #define CONTIN BIT(0) /* skip new lines to complete command */ #define ONEWORD BIT(1) /* single word for substitute() */ -#define ALIAS BIT(2) /* recognize alias */ -#define KEYWORD BIT(3) /* recognize keywords */ +#define ALIAS BIT(2) /* recognise alias */ +#define KEYWORD BIT(3) /* recognise keywords */ #define LETEXPR BIT(4) /* get expression inside (( )) */ #define VARASN BIT(5) /* check for var=word */ #define ARRAYVAR BIT(6) /* parse x[1 & 2] as one word */ diff --git a/shf.c b/shf.c index 844eea6..65e6c13 100644 --- a/shf.c +++ b/shf.c @@ -2,7 +2,7 @@ #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() */ #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... * * For shorts, we want sign extend for %d but not for %[oxu] - on 16 bit