add a timeout to --hold for the grub shell, fix a compilation error with gcc-2.7.2.3, and the command-line interface is switched to single-line editing mode.

This commit is contained in:
okuji 2000-08-30 07:00:16 +00:00
parent e8e3b99925
commit 454e26626c
7 changed files with 445 additions and 169 deletions

View file

@ -1,3 +1,29 @@
2000-08-30 OKUJI Yoshinori <okuji@gnu.org>
* configure.in (CPPFLAGS): Remove -Wundef by default. Add the
option only if the C compiler supports it, because GCC 2.7.x
doesn't support it.
* grub/main.c (longopts): The type of the argument for "hold" is
changed to OPTIONAL_ARGUMENT.
(main): If --hold is specified, check if OPTARG is zero. If so,
set HOLD to -1, otherwise, set it to the digit OPTARG.
If HOLD is greater than zero, decrease it once per loop.
2000-08-30 OKUJI Yoshinori <okuji@gnu.org>
The command-line interface is switched to single-line editing
mode.
* stage2/char_io.c [!STAGE1_5] (get_cmdline): Extensively
rewritten. The nested functions cl_print and cl_kill_to_end are
removed, cl_refresh, cl_backward, cl_forward and cl_delete are
added, and, cl_init and cl_insert are rewritten from scratch.
See the source code, for more information. I don't think this
kind of changes can be represented in ChangeLog.
[!STAGE1_5] (CMDLINE_WIDTH): New macro.
[!STAGE1_5] (CMDLINE_MARGIN): Likewise.
* stage2/shared.h (TERMINAL_DUMB): Likewise.
2000-08-28 OKUJI Yoshinori <okuji@gnu.org> 2000-08-28 OKUJI Yoshinori <okuji@gnu.org>
* grub/asmstub.c (console_putchar) [HAVE_LIBCURSES]: If * grub/asmstub.c (console_putchar) [HAVE_LIBCURSES]: If

7
NEWS
View file

@ -25,6 +25,13 @@ New in 0.5.96 - XXXX-XX-XX:
new commands, "serial" and "terminal" in the command-line and the new commands, "serial" and "terminal" in the command-line and the
menu. See the manual, for more details. menu. See the manual, for more details.
* Preserve the possible magic number used by Windows NT in a MBR. * Preserve the possible magic number used by Windows NT in a MBR.
* The command-line interface is switched to single-line editing mode.
* Only for developers: the configure script accepts
`--enable-serial-speed-simulation', which is useful when you want to
simulate the speed of a serial device on a psuedo terminal.
* Also only for developers: you can specify an optional argument to the
option `--hold' for the grub shell. The argument means how many
seconds the grub shell should wait until diving into the main routine.
New in 0.5.95 - 2000-06-27: New in 0.5.95 - 2000-06-27:
* NetBSD ELF kernel support is added. You have to specify the new option * NetBSD ELF kernel support is added. You have to specify the new option

134
configure vendored
View file

@ -1592,13 +1592,49 @@ fi
# Enforce coding standards. # Enforce coding standards.
CPPFLAGS="$CPPFLAGS -Wall -Wmissing-prototypes -Wunused -Wshadow" CPPFLAGS="$CPPFLAGS -Wall -Wmissing-prototypes -Wunused -Wshadow"
CPPFLAGS="$CPPFLAGS -Wpointer-arith -Wundef" CPPFLAGS="$CPPFLAGS -Wpointer-arith"
echo $ac_n "checking whether -Wundef works""... $ac_c" 1>&6
echo "configure:1599: checking whether -Wundef works" >&5
if eval "test \"`echo '$''{'undef_flag'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
saved_CPPFLAGS=$CPPFLAGS
CPPFLAGS="-Wundef"
cat > conftest.$ac_ext <<EOF
#line 1607 "configure"
#include "confdefs.h"
int main() {
; return 0; }
EOF
if { (eval echo configure:1614: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
undef_flag=yes
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
undef_flag=no
fi
rm -f conftest*
CPPFLAGS=$saved_CPPFLAGS
fi
echo "$ac_t""$undef_flag" 1>&6
if test "x$undef_flag" = xyes; then
CPPFLAGS="$CPPFLAGS -Wundef"
fi
if test "x$with_binutils" != x; then if test "x$with_binutils" != x; then
# Extract the first word of "objcopy", so it can be a program name with args. # Extract the first word of "objcopy", so it can be a program name with args.
set dummy objcopy; ac_word=$2 set dummy objcopy; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:1602: checking for $ac_word" >&5 echo "configure:1638: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_OBJCOPY'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_path_OBJCOPY'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -1634,7 +1670,7 @@ else
# Extract the first word of "${ac_tool_prefix}objcopy", so it can be a program name with args. # Extract the first word of "${ac_tool_prefix}objcopy", so it can be a program name with args.
set dummy ${ac_tool_prefix}objcopy; ac_word=$2 set dummy ${ac_tool_prefix}objcopy; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:1638: checking for $ac_word" >&5 echo "configure:1674: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_OBJCOPY'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_prog_OBJCOPY'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -1668,7 +1704,7 @@ fi
# Defined in acinclude.m4. # Defined in acinclude.m4.
echo $ac_n "checking if C symbols get an underscore after compilation""... $ac_c" 1>&6 echo $ac_n "checking if C symbols get an underscore after compilation""... $ac_c" 1>&6
echo "configure:1672: checking if C symbols get an underscore after compilation" >&5 echo "configure:1708: checking if C symbols get an underscore after compilation" >&5
if eval "test \"`echo '$''{'grub_cv_asm_uscore'+set}'`\" = set"; then if eval "test \"`echo '$''{'grub_cv_asm_uscore'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -1681,7 +1717,7 @@ func (int *list)
} }
EOF EOF
if { ac_try='${CC-cc} ${CFLAGS} -S conftest.c'; { (eval echo configure:1685: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.s; then if { ac_try='${CC-cc} ${CFLAGS} -S conftest.c'; { (eval echo configure:1721: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.s; then
true true
else else
{ echo "configure: error: ${CC-cc} failed to produce assembly code" 1>&2; exit 1; } { echo "configure: error: ${CC-cc} failed to produce assembly code" 1>&2; exit 1; }
@ -1707,7 +1743,7 @@ fi
echo "$ac_t""$grub_cv_asm_uscore" 1>&6 echo "$ac_t""$grub_cv_asm_uscore" 1>&6
echo $ac_n "checking whether ${OBJCOPY} works for absolute addresses""... $ac_c" 1>&6 echo $ac_n "checking whether ${OBJCOPY} works for absolute addresses""... $ac_c" 1>&6
echo "configure:1711: checking whether ${OBJCOPY} works for absolute addresses" >&5 echo "configure:1747: checking whether ${OBJCOPY} works for absolute addresses" >&5
if eval "test \"`echo '$''{'grub_cv_prog_objcopy_absolute'+set}'`\" = set"; then if eval "test \"`echo '$''{'grub_cv_prog_objcopy_absolute'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -1719,21 +1755,21 @@ cmain (void)
} }
EOF EOF
if { (eval echo configure:1723: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.o; then : if { (eval echo configure:1759: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.o; then :
else else
{ echo "configure: error: ${CC-cc} cannot compile C source code" 1>&2; exit 1; } { echo "configure: error: ${CC-cc} cannot compile C source code" 1>&2; exit 1; }
fi fi
grub_cv_prog_objcopy_absolute=yes grub_cv_prog_objcopy_absolute=yes
for link_addr in 2000 8000 7C00; do for link_addr in 2000 8000 7C00; do
if { ac_try='${CC-cc} ${CFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,$link_addr conftest.o -o conftest.exec'; { (eval echo configure:1729: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then : if { ac_try='${CC-cc} ${CFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,$link_addr conftest.o -o conftest.exec'; { (eval echo configure:1765: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then :
else else
{ echo "configure: error: ${CC-cc} cannot link at address $link_addr" 1>&2; exit 1; } { echo "configure: error: ${CC-cc} cannot link at address $link_addr" 1>&2; exit 1; }
fi fi
if { ac_try='${OBJCOPY-objcopy} -O binary conftest.exec conftest'; { (eval echo configure:1733: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then : if { ac_try='${OBJCOPY-objcopy} -O binary conftest.exec conftest'; { (eval echo configure:1769: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then :
else else
{ echo "configure: error: ${OBJCOPY-objcopy} cannot create binary files" 1>&2; exit 1; } { echo "configure: error: ${OBJCOPY-objcopy} cannot create binary files" 1>&2; exit 1; }
fi fi
if test ! -f conftest.old || { ac_try='cmp -s conftest.old conftest'; { (eval echo configure:1737: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then if test ! -f conftest.old || { ac_try='cmp -s conftest.old conftest'; { (eval echo configure:1773: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
mv -f conftest conftest.old mv -f conftest conftest.old
else else
grub_cv_prog_objcopy_absolute=no grub_cv_prog_objcopy_absolute=no
@ -1750,7 +1786,7 @@ fi
echo $ac_n "checking whether addr32 must be in the same line as the instruction""... $ac_c" 1>&6 echo $ac_n "checking whether addr32 must be in the same line as the instruction""... $ac_c" 1>&6
echo "configure:1754: checking whether addr32 must be in the same line as the instruction" >&5 echo "configure:1790: checking whether addr32 must be in the same line as the instruction" >&5
if eval "test \"`echo '$''{'grub_cv_asm_prefix_requirement'+set}'`\" = set"; then if eval "test \"`echo '$''{'grub_cv_asm_prefix_requirement'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -1759,7 +1795,7 @@ else
l1: addr32 movb %al, l1 l1: addr32 movb %al, l1
EOF EOF
if { ac_try='${CC-cc} ${CFLAGS} -c conftest.s'; { (eval echo configure:1763: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.o; then if { ac_try='${CC-cc} ${CFLAGS} -c conftest.s'; { (eval echo configure:1799: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.o; then
grub_cv_asm_prefix_requirement=yes grub_cv_asm_prefix_requirement=yes
else else
grub_cv_asm_prefix_requirement=no grub_cv_asm_prefix_requirement=no
@ -1791,7 +1827,7 @@ echo "$ac_t""$grub_cv_asm_prefix_requirement" 1>&6
echo $ac_n "checking for .code16 addr32 assembler support""... $ac_c" 1>&6 echo $ac_n "checking for .code16 addr32 assembler support""... $ac_c" 1>&6
echo "configure:1795: checking for .code16 addr32 assembler support" >&5 echo "configure:1831: checking for .code16 addr32 assembler support" >&5
if eval "test \"`echo '$''{'grub_cv_asm_addr32'+set}'`\" = set"; then if eval "test \"`echo '$''{'grub_cv_asm_addr32'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -1806,7 +1842,7 @@ else
sed -e s/@ADDR32@/addr32\;/ < conftest.s.in > conftest.s sed -e s/@ADDR32@/addr32\;/ < conftest.s.in > conftest.s
fi fi
if { ac_try='${CC-cc} ${CFLAGS} -c conftest.s'; { (eval echo configure:1810: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.o; then if { ac_try='${CC-cc} ${CFLAGS} -c conftest.s'; { (eval echo configure:1846: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.o; then
grub_cv_asm_addr32=yes grub_cv_asm_addr32=yes
else else
grub_cv_asm_addr32=no grub_cv_asm_addr32=no
@ -1823,7 +1859,7 @@ fi
echo $ac_n "checking whether an absolute indirect call/jump must not be prefixed with an asterisk""... $ac_c" 1>&6 echo $ac_n "checking whether an absolute indirect call/jump must not be prefixed with an asterisk""... $ac_c" 1>&6
echo "configure:1827: checking whether an absolute indirect call/jump must not be prefixed with an asterisk" >&5 echo "configure:1863: checking whether an absolute indirect call/jump must not be prefixed with an asterisk" >&5
if eval "test \"`echo '$''{'grub_cv_asm_absolute_without_asterisk'+set}'`\" = set"; then if eval "test \"`echo '$''{'grub_cv_asm_absolute_without_asterisk'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -1834,7 +1870,7 @@ offset:
.word 0 .word 0
EOF EOF
if { ac_try='${CC-cc} ${CFLAGS} -c conftest.s'; { (eval echo configure:1838: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.o; then if { ac_try='${CC-cc} ${CFLAGS} -c conftest.s'; { (eval echo configure:1874: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.o; then
grub_cv_asm_absolute_without_asterisk=no grub_cv_asm_absolute_without_asterisk=no
else else
grub_cv_asm_absolute_without_asterisk=yes grub_cv_asm_absolute_without_asterisk=yes
@ -1855,19 +1891,19 @@ echo "$ac_t""$grub_cv_asm_absolute_without_asterisk" 1>&6
echo $ac_n "checking if start is defined by the compiler""... $ac_c" 1>&6 echo $ac_n "checking if start is defined by the compiler""... $ac_c" 1>&6
echo "configure:1859: checking if start is defined by the compiler" >&5 echo "configure:1895: checking if start is defined by the compiler" >&5
if eval "test \"`echo '$''{'grub_cv_check_start_symbol'+set}'`\" = set"; then if eval "test \"`echo '$''{'grub_cv_check_start_symbol'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1864 "configure" #line 1900 "configure"
#include "confdefs.h" #include "confdefs.h"
int main() { int main() {
asm ("incl start") asm ("incl start")
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:1871: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then if { (eval echo configure:1907: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest* rm -rf conftest*
grub_cv_check_start_symbol=yes grub_cv_check_start_symbol=yes
else else
@ -1891,19 +1927,19 @@ echo "$ac_t""$grub_cv_check_start_symbol" 1>&6
echo $ac_n "checking if _start is defined by the compiler""... $ac_c" 1>&6 echo $ac_n "checking if _start is defined by the compiler""... $ac_c" 1>&6
echo "configure:1895: checking if _start is defined by the compiler" >&5 echo "configure:1931: checking if _start is defined by the compiler" >&5
if eval "test \"`echo '$''{'grub_cv_check_uscore_start_symbol'+set}'`\" = set"; then if eval "test \"`echo '$''{'grub_cv_check_uscore_start_symbol'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1900 "configure" #line 1936 "configure"
#include "confdefs.h" #include "confdefs.h"
int main() { int main() {
asm ("incl _start") asm ("incl _start")
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:1907: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then if { (eval echo configure:1943: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest* rm -rf conftest*
grub_cv_check_uscore_start_symbol=yes grub_cv_check_uscore_start_symbol=yes
else else
@ -1932,19 +1968,19 @@ fi
echo $ac_n "checking if __bss_start is defined by the compiler""... $ac_c" 1>&6 echo $ac_n "checking if __bss_start is defined by the compiler""... $ac_c" 1>&6
echo "configure:1936: checking if __bss_start is defined by the compiler" >&5 echo "configure:1972: checking if __bss_start is defined by the compiler" >&5
if eval "test \"`echo '$''{'grub_cv_check_uscore_uscore_bss_start_symbol'+set}'`\" = set"; then if eval "test \"`echo '$''{'grub_cv_check_uscore_uscore_bss_start_symbol'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1941 "configure" #line 1977 "configure"
#include "confdefs.h" #include "confdefs.h"
int main() { int main() {
asm ("incl __bss_start") asm ("incl __bss_start")
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:1948: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then if { (eval echo configure:1984: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest* rm -rf conftest*
grub_cv_check_uscore_uscore_bss_start_symbol=yes grub_cv_check_uscore_uscore_bss_start_symbol=yes
else else
@ -1968,19 +2004,19 @@ echo "$ac_t""$grub_cv_check_uscore_uscore_bss_start_symbol" 1>&6
echo $ac_n "checking if _edata is defined by the compiler""... $ac_c" 1>&6 echo $ac_n "checking if _edata is defined by the compiler""... $ac_c" 1>&6
echo "configure:1972: checking if _edata is defined by the compiler" >&5 echo "configure:2008: checking if _edata is defined by the compiler" >&5
if eval "test \"`echo '$''{'grub_cv_check_uscore_edata_symbol'+set}'`\" = set"; then if eval "test \"`echo '$''{'grub_cv_check_uscore_edata_symbol'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1977 "configure" #line 2013 "configure"
#include "confdefs.h" #include "confdefs.h"
int main() { int main() {
asm ("incl _edata") asm ("incl _edata")
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:1984: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then if { (eval echo configure:2020: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest* rm -rf conftest*
grub_cv_check_uscore_edata_symbol=yes grub_cv_check_uscore_edata_symbol=yes
else else
@ -2004,19 +2040,19 @@ echo "$ac_t""$grub_cv_check_uscore_edata_symbol" 1>&6
echo $ac_n "checking if edata is defined by the compiler""... $ac_c" 1>&6 echo $ac_n "checking if edata is defined by the compiler""... $ac_c" 1>&6
echo "configure:2008: checking if edata is defined by the compiler" >&5 echo "configure:2044: checking if edata is defined by the compiler" >&5
if eval "test \"`echo '$''{'grub_cv_check_edata_symbol'+set}'`\" = set"; then if eval "test \"`echo '$''{'grub_cv_check_edata_symbol'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 2013 "configure" #line 2049 "configure"
#include "confdefs.h" #include "confdefs.h"
int main() { int main() {
asm ("incl edata") asm ("incl edata")
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:2020: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then if { (eval echo configure:2056: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest* rm -rf conftest*
grub_cv_check_edata_symbol=yes grub_cv_check_edata_symbol=yes
else else
@ -2046,19 +2082,19 @@ fi
echo $ac_n "checking if end is defined by the compiler""... $ac_c" 1>&6 echo $ac_n "checking if end is defined by the compiler""... $ac_c" 1>&6
echo "configure:2050: checking if end is defined by the compiler" >&5 echo "configure:2086: checking if end is defined by the compiler" >&5
if eval "test \"`echo '$''{'grub_cv_check_end_symbol'+set}'`\" = set"; then if eval "test \"`echo '$''{'grub_cv_check_end_symbol'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 2055 "configure" #line 2091 "configure"
#include "confdefs.h" #include "confdefs.h"
int main() { int main() {
asm ("incl end") asm ("incl end")
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:2062: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then if { (eval echo configure:2098: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest* rm -rf conftest*
grub_cv_check_end_symbol=yes grub_cv_check_end_symbol=yes
else else
@ -2082,19 +2118,19 @@ echo "$ac_t""$grub_cv_check_end_symbol" 1>&6
echo $ac_n "checking if _end is defined by the compiler""... $ac_c" 1>&6 echo $ac_n "checking if _end is defined by the compiler""... $ac_c" 1>&6
echo "configure:2086: checking if _end is defined by the compiler" >&5 echo "configure:2122: checking if _end is defined by the compiler" >&5
if eval "test \"`echo '$''{'grub_cv_check_uscore_end_symbol'+set}'`\" = set"; then if eval "test \"`echo '$''{'grub_cv_check_uscore_end_symbol'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 2091 "configure" #line 2127 "configure"
#include "confdefs.h" #include "confdefs.h"
int main() { int main() {
asm ("incl _end") asm ("incl _end")
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:2098: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then if { (eval echo configure:2134: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest* rm -rf conftest*
grub_cv_check_uscore_end_symbol=yes grub_cv_check_uscore_end_symbol=yes
else else
@ -2132,7 +2168,7 @@ fi
# Get the filename or the whole disk and open it. # Get the filename or the whole disk and open it.
# Known to work on NetBSD. # Known to work on NetBSD.
echo $ac_n "checking for opendisk in -lutil""... $ac_c" 1>&6 echo $ac_n "checking for opendisk in -lutil""... $ac_c" 1>&6
echo "configure:2136: checking for opendisk in -lutil" >&5 echo "configure:2172: checking for opendisk in -lutil" >&5
ac_lib_var=`echo util'_'opendisk | sed 'y%./+-%__p_%'` ac_lib_var=`echo util'_'opendisk | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
@ -2140,7 +2176,7 @@ else
ac_save_LIBS="$LIBS" ac_save_LIBS="$LIBS"
LIBS="-lutil $LIBS" LIBS="-lutil $LIBS"
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 2144 "configure" #line 2180 "configure"
#include "confdefs.h" #include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */ /* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2 /* We use char because int might match the return type of a gcc2
@ -2151,7 +2187,7 @@ int main() {
opendisk() opendisk()
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:2155: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then if { (eval echo configure:2191: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest* rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes" eval "ac_cv_lib_$ac_lib_var=yes"
else else
@ -2179,7 +2215,7 @@ fi
# Unless the user specify --without-curses, check for curses. # Unless the user specify --without-curses, check for curses.
if test "x$with_curses" != "xno"; then if test "x$with_curses" != "xno"; then
echo $ac_n "checking for wgetch in -lncurses""... $ac_c" 1>&6 echo $ac_n "checking for wgetch in -lncurses""... $ac_c" 1>&6
echo "configure:2183: checking for wgetch in -lncurses" >&5 echo "configure:2219: checking for wgetch in -lncurses" >&5
ac_lib_var=`echo ncurses'_'wgetch | sed 'y%./+-%__p_%'` ac_lib_var=`echo ncurses'_'wgetch | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
@ -2187,7 +2223,7 @@ else
ac_save_LIBS="$LIBS" ac_save_LIBS="$LIBS"
LIBS="-lncurses $LIBS" LIBS="-lncurses $LIBS"
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 2191 "configure" #line 2227 "configure"
#include "confdefs.h" #include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */ /* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2 /* We use char because int might match the return type of a gcc2
@ -2198,7 +2234,7 @@ int main() {
wgetch() wgetch()
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:2202: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then if { (eval echo configure:2238: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest* rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes" eval "ac_cv_lib_$ac_lib_var=yes"
else else
@ -2221,7 +2257,7 @@ EOF
else else
echo "$ac_t""no" 1>&6 echo "$ac_t""no" 1>&6
echo $ac_n "checking for wgetch in -lcurses""... $ac_c" 1>&6 echo $ac_n "checking for wgetch in -lcurses""... $ac_c" 1>&6
echo "configure:2225: checking for wgetch in -lcurses" >&5 echo "configure:2261: checking for wgetch in -lcurses" >&5
ac_lib_var=`echo curses'_'wgetch | sed 'y%./+-%__p_%'` ac_lib_var=`echo curses'_'wgetch | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
@ -2229,7 +2265,7 @@ else
ac_save_LIBS="$LIBS" ac_save_LIBS="$LIBS"
LIBS="-lcurses $LIBS" LIBS="-lcurses $LIBS"
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 2233 "configure" #line 2269 "configure"
#include "confdefs.h" #include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */ /* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2 /* We use char because int might match the return type of a gcc2
@ -2240,7 +2276,7 @@ int main() {
wgetch() wgetch()
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:2244: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then if { (eval echo configure:2280: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest* rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes" eval "ac_cv_lib_$ac_lib_var=yes"
else else
@ -2275,17 +2311,17 @@ for ac_hdr in string.h strings.h ncurses/curses.h ncurses.h curses.h
do do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:2279: checking for $ac_hdr" >&5 echo "configure:2315: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 2284 "configure" #line 2320 "configure"
#include "confdefs.h" #include "confdefs.h"
#include <$ac_hdr> #include <$ac_hdr>
EOF EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:2289: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } { (eval echo configure:2325: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then if test -z "$ac_err"; then
rm -rf conftest* rm -rf conftest*

View file

@ -94,7 +94,18 @@ AC_SUBST(GRUB_CFLAGS)
# Enforce coding standards. # Enforce coding standards.
CPPFLAGS="$CPPFLAGS -Wall -Wmissing-prototypes -Wunused -Wshadow" CPPFLAGS="$CPPFLAGS -Wall -Wmissing-prototypes -Wunused -Wshadow"
CPPFLAGS="$CPPFLAGS -Wpointer-arith -Wundef" CPPFLAGS="$CPPFLAGS -Wpointer-arith"
AC_CACHE_CHECK([whether -Wundef works], undef_flag, [
saved_CPPFLAGS=$CPPFLAGS
CPPFLAGS="-Wundef"
AC_TRY_COMPILE(, , undef_flag=yes, undef_flag=no)
CPPFLAGS=$saved_CPPFLAGS
])
if test "x$undef_flag" = xyes; then
CPPFLAGS="$CPPFLAGS -Wundef"
fi
if test "x$with_binutils" != x; then if test "x$with_binutils" != x; then
dnl AC_PATH_TOOL(OBJCOPY, objcopy, , "$with_binutils:$PATH") dnl AC_PATH_TOOL(OBJCOPY, objcopy, , "$with_binutils:$PATH")

View file

@ -66,7 +66,7 @@ static struct option longopts[] =
{"config-file", required_argument, 0, OPT_CONFIG_FILE}, {"config-file", required_argument, 0, OPT_CONFIG_FILE},
{"device-map", required_argument, 0, OPT_DEVICE_MAP}, {"device-map", required_argument, 0, OPT_DEVICE_MAP},
{"help", no_argument, 0, OPT_HELP}, {"help", no_argument, 0, OPT_HELP},
{"hold", no_argument, 0, OPT_HOLD}, {"hold", optional_argument, 0, OPT_HOLD},
{"install-partition", required_argument, 0, OPT_INSTALL_PARTITION}, {"install-partition", required_argument, 0, OPT_INSTALL_PARTITION},
{"no-config-file", no_argument, 0, OPT_NO_CONFIG_FILE}, {"no-config-file", no_argument, 0, OPT_NO_CONFIG_FILE},
{"no-curses", no_argument, 0, OPT_NO_CURSES}, {"no-curses", no_argument, 0, OPT_NO_CURSES},
@ -153,7 +153,10 @@ main (int argc, char **argv)
break; break;
case OPT_HOLD: case OPT_HOLD:
hold = 1; if (! optarg)
hold = -1;
else
hold = atoi (optarg);
break; break;
case OPT_CONFIG_FILE: case OPT_CONFIG_FILE:
@ -224,7 +227,12 @@ main (int argc, char **argv)
printf ("Run \"gdb %s %d\", and set HOLD to zero.\n", printf ("Run \"gdb %s %d\", and set HOLD to zero.\n",
program_name, (int) getpid ()); program_name, (int) getpid ());
while (hold) while (hold)
{
if (hold > 0)
hold--;
sleep (1); sleep (1);
}
/* Transfer control to the stage2 simulator. */ /* Transfer control to the stage2 simulator. */
exit (grub_stage2 ()); exit (grub_stage2 ());

View file

@ -222,11 +222,47 @@ int
get_cmdline (char *prompt, char *cmdline, int maxlen, get_cmdline (char *prompt, char *cmdline, int maxlen,
int echo_char, int readline) int echo_char, int readline)
{ {
int ystart, yend, xend, lpos, c; /* This is a rather complicated function. So explain the concept.
A command-line consists of ``section''s. A section is a part of the
line which may be displayed on the screen, but a section is never
displayed with another section simultaneously.
Each section is basically 77 or less characters, but the exception
is the first section, which is 78 or less characters, because the
starting point is special. See below.
The first section contains a prompt and a command-line (or the
first part of a command-line when it is too long to be fit in the
screen). So, in the first section, the number of command-line
characters displayed is 78 minus the length of the prompt (or
less). If the command-line has more characters, `>' is put at the
position 78 (zero-origin), to inform the user of the hidden
characters.
Other sections always have `<' at the first position, since there
is absolutely a section before each section. If there is a section
after another section, this section consists of 77 characters and
`>' at the last position. The last section has 77 or less
characters and doesn't have `>'.
Each section other than the last shares some characters with the
previous section. This region is called ``margin''. If the cursor
is put at the magin which is shared by the first section and the
second, the first section is displayed. Otherwise, a displayed
section is switched to another section, only if the cursor is put
outside that section. */
/* XXX: These should be defined in shared.h, but I leave these here,
until this code is freezed. */
#define CMDLINE_WIDTH 78
#define CMDLINE_MARGIN 10
int xpos, lpos, c, section;
/* The length of PROMPT. */ /* The length of PROMPT. */
int plen = 0; int plen;
/* The length of the command-line. */ /* The length of the command-line. */
int llen = 0; int llen;
/* The index for the history. */ /* The index for the history. */
int history = -1; int history = -1;
/* The working buffer for the command-line. */ /* The working buffer for the command-line. */
@ -234,90 +270,276 @@ get_cmdline (char *prompt, char *cmdline, int maxlen,
/* The kill buffer. */ /* The kill buffer. */
char *kill_buf = (char *) KILL_BUF; char *kill_buf = (char *) KILL_BUF;
/* nested function definition for code simplicity */ /* Nested function definitions for code simplicity. */
static void cl_print (char *str, int real_echo_char)
/* The forward declarations of nested functions are prefixed
with `auto'. */
auto void cl_refresh (int full, int len);
auto void cl_backward (int count);
auto void cl_forward (int count);
auto void cl_insert (const char *str);
auto void cl_delete (int count);
auto void cl_init (void);
/* Move the cursor backward. */
void cl_backward (int count)
{ {
while (*str != 0) lpos -= count;
{
putchar (real_echo_char ? real_echo_char : *str); /* If the cursor is in the first section, display the first section
str++; instead of the second. */
if (++xend > 78) if (section == 1 && plen + lpos < CMDLINE_WIDTH)
{ cl_refresh (1, 0);
xend = 0; else if (xpos - count < 1)
putchar (' '); cl_refresh (1, 0);
if (yend == (getxy () & 0xff))
ystart--;
else else
yend++;
}
}
}
/* nested function definition for code simplicity */
static void cl_setcpos (void)
{
yend = ((lpos + plen) / 79) + ystart;
xend = ((lpos + plen) % 79);
gotoxy (xend, yend);
}
/* nested function definition for initial command-line printing */
static void cl_init ()
{
/* distinguish us from other lines and error messages! */
putchar ('\n');
/* print full line and set position here */
ystart = (getxy () & 0xff);
yend = ystart;
xend = 0;
cl_print (prompt, 0);
cl_print (buf, echo_char);
cl_setcpos ();
}
/* nested function definition for erasing to the end of the line */
static void cl_kill_to_end ()
{ {
int i; int i;
buf[lpos] = 0;
for (i = lpos; i <= llen; i++) xpos -= count;
if (! (terminal & TERMINAL_DUMB))
{ {
if (i && ((i + plen) % 79) == 0) if (terminal & TERMINAL_CONSOLE)
putchar (' '); {
putchar (' '); int y = getxy () & 0xFF;
gotoxy (xpos, y);
return;
} }
llen = lpos; # ifdef SUPPORT_SERIAL
cl_setcpos (); else if (terminal & TERMINAL_SERIAL)
{
/* Ugly optimization. */
if (count > 4)
{
grub_printf ("\e[%dD", count);
return;
}
}
# endif /* SUPPORT_SERIAL */
} }
static void cl_insert (const char *str) for (i = 0; i < count; i++)
grub_putchar ('\b');
}
}
/* Move the cursor forward. */
void cl_forward (int count)
{
lpos += count;
/* If the cursor goes outside, scroll the screen to the right. */
if (xpos + count >= CMDLINE_WIDTH)
cl_refresh (1, 0);
else
{
int i;
xpos += count;
if (! (terminal & TERMINAL_DUMB))
{
if (terminal & TERMINAL_CONSOLE)
{
int y = getxy () & 0xFF;
gotoxy (xpos, y);
return;
}
# ifdef SUPPORT_SERIAL
else if (terminal & TERMINAL_SERIAL)
{
/* Ugly optimization. */
if (count > 4)
{
grub_printf ("\e[%dC", count);
return;
}
}
# endif /* SUPPORT_SERIAL */
}
for (i = lpos - count; i < lpos; i++)
{
if (! echo_char)
grub_putchar (buf[i]);
else
grub_putchar (echo_char);
}
}
}
/* Refresh the screen. If FULL is true, redraw the full line, otherwise,
only LEN characters from LPOS. */
void cl_refresh (int full, int len)
{
int i;
int start;
int pos = xpos;
if (full)
{
/* Recompute the section number. */
if (lpos + plen < CMDLINE_WIDTH)
section = 0;
else
section = ((lpos + plen - CMDLINE_WIDTH)
/ (CMDLINE_WIDTH - 1 - CMDLINE_MARGIN) + 1);
/* From the start to the end. */
len = CMDLINE_WIDTH;
pos = 0;
grub_putchar ('\r');
/* If SECTION is the first section, print the prompt, otherwise,
print `<'. */
if (section == 0)
{
grub_printf ("%s", prompt);
len -= plen;
pos += plen;
}
else
{
grub_putchar ('<');
len--;
pos++;
}
}
/* Compute the index to start writing BUF and the resulting position
on the screen. */
if (section == 0)
{
int offset = 0;
if (! full)
offset = xpos - plen;
start = 0;
xpos = lpos + plen;
start += offset;
}
else
{
int offset = 0;
if (! full)
offset = xpos - 1;
start = ((section - 1) * (CMDLINE_WIDTH - 1 - CMDLINE_MARGIN)
+ CMDLINE_WIDTH - plen - CMDLINE_MARGIN);
xpos = lpos + 1 - start;
start += offset;
}
/* Print BUF. If ECHO_CHAR is not zero, put it instead. */
for (i = start; i < start + len && i < llen; i++)
{
if (! echo_char)
grub_putchar (buf[i]);
else
grub_putchar (echo_char);
pos++;
}
/* Fill up the rest of the line with spaces. */
for (; i < start + len; i++)
{
grub_putchar (' ');
pos++;
}
/* If the cursor is at the last position, put `>' or a space,
depending on if there are more characters in BUF. */
if (pos == CMDLINE_WIDTH)
{
if (start + len < llen)
grub_putchar ('>');
else
grub_putchar (' ');
pos++;
}
/* Back to XPOS. */
if (! (terminal & TERMINAL_DUMB))
{
if (terminal & TERMINAL_CONSOLE)
{
int y = getxy () & 0xFF;
gotoxy (xpos, y);
return;
}
# ifdef SUPPORT_SERIAL
else if (terminal & TERMINAL_SERIAL)
{
/* Ugly optimization. */
if (pos - xpos > 4)
{
grub_printf ("\e[%dD", pos - xpos);
return;
}
}
# endif /* SUPPORT_SERIAL */
}
for (i = 0; i < pos - xpos; i++)
grub_putchar ('\b');
}
/* Initialize the command-line. */
void cl_init (void)
{
/* Distinguish us from other lines and error messages! */
grub_putchar ('\n');
/* Print full line and set position here. */
cl_refresh (1, 0);
}
/* Insert STR to BUF. */
void cl_insert (const char *str)
{ {
int l = grub_strlen (str); int l = grub_strlen (str);
if (llen + l < maxlen) if (llen + l < maxlen)
{ {
if (lpos == llen) if (lpos == llen)
{
grub_memmove (buf + lpos, str, l + 1); grub_memmove (buf + lpos, str, l + 1);
cl_setcpos ();
cl_print (buf + lpos, echo_char);
lpos += l;
cl_setcpos ();
}
else else
{ {
grub_memmove (buf + lpos + l, buf + lpos, llen - lpos + 1); grub_memmove (buf + lpos + l, buf + lpos, llen - lpos + 1);
grub_memmove (buf + lpos, str, l); grub_memmove (buf + lpos, str, l);
cl_setcpos ();
cl_print (buf + lpos, echo_char);
lpos += l;
cl_setcpos ();
} }
llen += l; llen += l;
lpos += l;
if (xpos + l >= CMDLINE_WIDTH)
cl_refresh (1, 0);
else if (xpos + l + llen - lpos > CMDLINE_WIDTH)
cl_refresh (0, CMDLINE_WIDTH - xpos);
else
cl_refresh (0, l + llen - lpos);
} }
} }
/* Delete COUNT characters in BUF. */
void cl_delete (int count)
{
grub_memmove (buf + lpos, buf + lpos + count, llen - count + 1);
llen -= count;
if (xpos + llen + count - lpos > CMDLINE_WIDTH)
cl_refresh (0, CMDLINE_WIDTH - xpos);
else
cl_refresh (0, llen + count - lpos);
}
plen = grub_strlen (prompt); plen = grub_strlen (prompt);
llen = grub_strlen (cmdline); llen = grub_strlen (cmdline);
@ -395,14 +617,10 @@ get_cmdline (char *prompt, char *cmdline, int maxlen,
if (ret > 0) if (ret > 0)
{ {
/* There is more than one candidates, so print /* There are more than one candidates, so print
the list. */ the list. */
/* Go to the part after the line here. */
yend = ((llen + plen) / 79) + ystart;
grub_putchar ('\n'); grub_putchar ('\n');
gotoxy (0, getxy () & 0xff);
print_completions (is_filename, 0); print_completions (is_filename, 0);
errnum = ERR_NONE; errnum = ERR_NONE;
} }
@ -417,26 +635,18 @@ get_cmdline (char *prompt, char *cmdline, int maxlen,
} }
break; break;
case 1: /* C-a go to beginning of line */ case 1: /* C-a go to beginning of line */
lpos = 0; cl_backward (lpos);
cl_setcpos ();
break; break;
case 5: /* C-e go to end of line */ case 5: /* C-e go to end of line */
lpos = llen; cl_forward (llen - lpos);
cl_setcpos ();
break; break;
case 6: /* C-f forward one character */ case 6: /* C-f forward one character */
if (lpos < llen) if (lpos < llen)
{ cl_forward (1);
lpos++;
cl_setcpos ();
}
break; break;
case 2: /* C-b backward one character */ case 2: /* C-b backward one character */
if (lpos > 0) if (lpos > 0)
{ cl_backward (1);
lpos--;
cl_setcpos ();
}
break; break;
case 21: /* C-u kill to beginning of line */ case 21: /* C-u kill to beginning of line */
if (lpos == 0) if (lpos == 0)
@ -444,21 +654,21 @@ get_cmdline (char *prompt, char *cmdline, int maxlen,
/* Copy the string being deleted to KILL_BUF. */ /* Copy the string being deleted to KILL_BUF. */
grub_memmove (kill_buf, buf, lpos); grub_memmove (kill_buf, buf, lpos);
kill_buf[lpos] = 0; kill_buf[lpos] = 0;
grub_memmove (buf, buf + lpos, llen - lpos + 1); {
lpos = llen - lpos; /* XXX: Not very clever. */
cl_setcpos ();
cl_kill_to_end (); int count = lpos;
lpos = 0;
cl_setcpos (); cl_backward (lpos);
cl_print (buf, echo_char); cl_delete (count);
cl_setcpos (); }
break; break;
case 11: /* C-k kill to end of line */ case 11: /* C-k kill to end of line */
if (lpos == llen) if (lpos == llen)
break; break;
/* Copy the string being deleted to KILL_BUF. */ /* Copy the string being deleted to KILL_BUF. */
grub_memmove (kill_buf, buf + lpos, llen - lpos + 1); grub_memmove (kill_buf, buf + lpos, llen - lpos + 1);
cl_kill_to_end (); cl_delete (llen - lpos);
break; break;
case 25: /* C-y yank the kill buffer */ case 25: /* C-y yank the kill buffer */
cl_insert (kill_buf); cl_insert (kill_buf);
@ -482,14 +692,10 @@ get_cmdline (char *prompt, char *cmdline, int maxlen,
break; break;
} }
lpos = 0;
cl_setcpos ();
cl_kill_to_end ();
grub_strcpy (buf, p); grub_strcpy (buf, p);
llen = grub_strlen (buf); llen = grub_strlen (buf);
lpos = llen; lpos = llen;
cl_print (buf, 0); cl_refresh (1, 0);
cl_setcpos ();
} }
break; break;
case 14: /* C-n fetch the next command */ case 14: /* C-n fetch the next command */
@ -509,14 +715,10 @@ get_cmdline (char *prompt, char *cmdline, int maxlen,
if (! p) if (! p)
p = cmdline; p = cmdline;
lpos = 0;
cl_setcpos ();
cl_kill_to_end ();
grub_strcpy (buf, p); grub_strcpy (buf, p);
llen = grub_strlen (buf); llen = grub_strlen (buf);
lpos = llen; lpos = llen;
cl_print (buf, 0); cl_refresh (1, 0);
cl_setcpos ();
} }
break; break;
} }
@ -532,28 +734,16 @@ get_cmdline (char *prompt, char *cmdline, int maxlen,
case 4: /* C-d delete character under cursor */ case 4: /* C-d delete character under cursor */
if (lpos == llen) if (lpos == llen)
break; break;
lpos++; cl_delete (1);
/* fallthrough is on purpose! */ break;
case 8: /* C-h backspace */ case 8: /* C-h backspace */
# ifdef GRUB_UTIL # ifdef GRUB_UTIL
case 127: /* also backspace */ case 127: /* also backspace */
# endif # endif
if (lpos > 0) if (lpos > 0)
{ {
int i; cl_backward (1);
grub_memmove (buf + lpos - 1, buf + lpos, llen - lpos + 1); cl_delete (1);
i = lpos;
lpos = llen - 1;
cl_setcpos ();
putchar (' ');
lpos = i - 1; /* restore lpos and decrement */
llen--;
cl_setcpos ();
if (lpos != llen)
{
cl_print (buf + lpos, echo_char);
cl_setcpos ();
}
} }
break; break;
default: /* insert printable character into line */ default: /* insert printable character into line */
@ -568,11 +758,7 @@ get_cmdline (char *prompt, char *cmdline, int maxlen,
} }
} }
/* Move the cursor to the end of the command. */
lpos = llen;
cl_setcpos ();
grub_putchar ('\n'); grub_putchar ('\n');
gotoxy (0, getxy () & 0xff);
/* If ECHO_CHAR is NUL, remove the leading spaces. */ /* If ECHO_CHAR is NUL, remove the leading spaces. */
lpos = 0; lpos = 0;

View file

@ -742,6 +742,8 @@ extern int terminal;
#define TERMINAL_CONSOLE (1 << 0) /* keyboard and screen */ #define TERMINAL_CONSOLE (1 << 0) /* keyboard and screen */
#define TERMINAL_SERIAL (1 << 1) /* serial console */ #define TERMINAL_SERIAL (1 << 1) /* serial console */
#define TERMINAL_DUMB (1 << 16) /* dumb terminal */
void init_builtins (void); void init_builtins (void);
void init_config (void); void init_config (void);
char *skip_to (int after_equal, char *cmdline); char *skip_to (int after_equal, char *cmdline);