• improve comments

• do shave off 20 bytes from c_test() and get rid of the ugly stack
  variable and double “using” despite not parsing
This commit is contained in:
tg 2011-12-02 22:55:49 +00:00
parent 2fb9df56e4
commit 1ac636670f
4 changed files with 66 additions and 34 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.491 2011/11/26 17:56:29 tg Exp $'
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.492 2011/12/02 22:55:45 tg Exp $'
#-
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
# Thorsten Glaser <tg@mirbsd.org>
@ -22,17 +22,7 @@ srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.491 2011/11/26 17:56:29 tg Exp $'
# People analysing the output must whitelist conftest.c for any kind
# of compiler warning checks (mirtoconf is by design not quiet).
#
# Environment used: CC CFLAGS CPPFLAGS LDFLAGS LIBS NOWARN NROFF
# TARGET_OS TARGET_OSREV
# Feature selectors: USE_PRINTF_BUILTIN
# CPPFLAGS recognised: MKSH_MIDNIGHTBSD01ASH_COMPAT MKSH_CONSERVATIVE_FDS
# MKSH_DONT_EMIT_IDSTRING MKSH_NO_DEPRECATED_WARNING
# MKSH_DISABLE_DEPRECATED MKSH_ASSUME_UTF8 MKSH_A4PB
# MKSH_SMALL MKSH_BINSHREDUCED MKSH_NOPROSPECTOFWORK
# MKSH_UNEMPLOYED MKSH_NO_LIMITS MKSH_DEFAULT_TMPDIR
# MKSH_DEFAULT_EXECSHELL MKSHRC_PATH MKSH_CLS_STRING
# MKSH_CLRTOEOL_STRING MKSH_NO_EXTERNAL_CAT
# MKSH_NOPWNAM MKSH_S_NOVI
# Used environment documentation is at the end of this file.
LC_ALL=C
export LC_ALL
@ -1183,7 +1173,7 @@ else
#define EXTERN
#define MKSH_INCLUDES_ONLY
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.491 2011/11/26 17:56:29 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.492 2011/12/02 22:55:45 tg Exp $");
int main(void) { printf("Hello, World!\n"); return (0); }
EOF
case $cm in
@ -1785,3 +1775,51 @@ $e
$e Run the regression test suite: ./test.sh
$e Please also read the sample file dot.mkshrc and the fine manual.
exit 0
: <<'EOD'
=== Environment used ===
==== build environment ====
CC default: cc
CFLAGS if empty, defaults to -xO2 or +O2
or -O3 -qstrict or -O2, per compiler
CPPFLAGS default empty
LDFLAGS default empty; added before sources
LIBS default empty; added after sources
[Interix] default: -lcrypt (XXX still needed?)
NOWARN -Wno-error or similar
NROFF default: nroff
TARGET_OS default: $(uname -s || uname)
TARGET_OSREV [QNX] default: $(uname -r)
==== feature selectors ====
USE_PRINTF_BUILTIN 1 to include (unsupported) printf(1) as builtin
===== general format =====
HAVE_STRLEN ac_test
HAVE_STRING_H ac_header
HAVE_CAN_FSTACKPROTECTORALL ac_flags
==== cpp definitions ====
MKSHRC_PATH "~/.mkshrc" (do not change)
MKSH_A4PB force use of arc4random_pushb
MKSH_ASSUME_UTF8 (0=disabled, 1=enabled; default: unset)
MKSH_BINSHREDUCED if */sh or */-sh, enable set -o sh
MKSH_CLRTOEOL_STRING "\033[K"
MKSH_CLS_STRING "\033[;H\033[J"
MKSH_CONSERVATIVE_FDS fd 0-9 for scripts, shell only up to 31
MKSH_DEFAULT_EXECSHELL "/bin/sh" (do not change)
MKSH_DEFAULT_TMPDIR "/tmp" (do not change)
MKSH_DISABLE_DEPRECATED disable code paths scheduled for later removal
MKSH_DONT_EMIT_IDSTRING omit RCS IDs from binary
MKSH_MIDNIGHTBSD01ASH_COMPAT set -o sh: additional compatibility quirk
MKSH_NOPROSPECTOFWORK disable jobs, co-processes, etc. (do not use)
MKSH_NOPWNAM skip PAM calls, for -static on eglibc, Solaris
MKSH_NO_DEPRECATED_WARNING omit warning when deprecated stuff is run
MKSH_NO_EXTERNAL_CAT omit hack to skip cat builtin when flags passed
MKSH_NO_LIMITS omit ulimit code
MKSH_SMALL omit some code, optimise hard for size (slower)
MKSH_S_NOVI disable Vi editing mode (default if MKSH_SMALL)
MKSH_UNEMPLOYED disable job control (but not jobs/co-processes)
EOD

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.497 2011/11/30 21:34:10 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.498 2011/12/02 22:55:46 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 $
@ -28,7 +28,7 @@
# http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD
expected-stdout:
@(#)MIRBSD KSH R40 2011/11/30
@(#)MIRBSD KSH R40 2011/12/02
description:
Check version of shell.
stdin:

26
funcs.c
View File

@ -38,7 +38,7 @@
#endif
#endif
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.200 2011/11/30 21:34:12 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.201 2011/12/02 22:55:48 tg Exp $");
#if HAVE_KILLPG
/*
@ -2697,7 +2697,7 @@ c_mknod(const char **wp)
#endif
/*-
test(1) accepts the following grammar:
test(1) roughly accepts the following grammar:
oexpr ::= aexpr | aexpr "-o" oexpr ;
aexpr ::= nexpr | nexpr "-a" aexpr ;
nexpr ::= primary | "!" nexpr ;
@ -2713,9 +2713,9 @@ c_mknod(const char **wp)
binary-operator ::= "="|"=="|"!="|"-eq"|"-ne"|"-ge"|"-gt"|"-le"|"-lt"|
"-nt"|"-ot"|"-ef"|
"<"|">" # rules used for [[ .. ]] expressions
"<"|">" # rules used for [[ ... ]] expressions
;
operand ::= <any thing>
operand ::= <anything>
*/
/* POSIX says > 1 for errors */
@ -2778,19 +2778,13 @@ c_test(const char **wp)
case 3:
ptest_three:
swp = te.pos.wp;
/* skip lhs, without evaluation */
(*te.getopnd)(&te, TO_NONOP, false);
/* inside knowledge shows ptest_getopnd never evaluates */
/* skip lhs, without evaluation; assign with */
lhs = (*te.getopnd)(&te, TO_NONOP, true);
if ((op = (*te.isa)(&te, TM_BINOP))) {
const char *rhs;
/* read rhs, with evaluation */
rhs = (*te.getopnd)(&te, op, true);
/* back up to lhs */
te.pos.wp = swp;
/* re-read lhs, with evaluation */
lhs = (*te.getopnd)(&te, op, true);
/* finally run the test of lhs op rhs */
rv = (*te.eval)(&te, op, lhs, rhs, true);
/* test lhs op rhs */
rv = (*te.eval)(&te, op, lhs,
(*te.getopnd)(&te, op, true), true);
goto ptest_out;
}
/* back up to lhs */

4
sh.h
View File

@ -151,9 +151,9 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.506 2011/11/30 21:34:15 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.507 2011/12/02 22:55:49 tg Exp $");
#endif
#define MKSH_VERSION "R40 2011/11/30"
#define MKSH_VERSION "R40 2011/12/02"
#ifndef MKSH_INCLUDES_ONLY