From: Vladimir 'phcoder' Serbinenko Date: Fri, 2 Jul 2010 17:35:07 +0000 (+0200) Subject: Merge mainline into bidi X-Git-Tag: 1.99~763^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e8d0a8f85cc76839547f35be991cb1057f58e9fb;p=thirdparty%2Fgrub.git Merge mainline into bidi --- e8d0a8f85cc76839547f35be991cb1057f58e9fb diff --cc commands/cat.c index 427da14e3,289cf7352..77a4cc793 --- a/commands/cat.c +++ b/commands/cat.c @@@ -53,7 -62,12 +62,12 @@@ grub_cmd_cat (grub_extcmd_t cmd, int ar unsigned char c = buf[i]; if ((grub_isprint (c) || grub_isspace (c)) && c != '\r') - grub_putchar (c); + grub_printf ("%c", c); + else if (dos && c == '\r' && i + 1 < size && buf[i + 1] == '\n') + { - grub_putchar ('\n'); ++ grub_printf ("\n"); + i++; + } else { grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT); diff --cc commands/help.c index cca4ae45b,ecf77fa4c..964f8f5ac --- a/commands/help.c +++ b/commands/help.c @@@ -33,88 -33,59 +33,64 @@@ grub_cmd_help (grub_extcmd_t ext __attr int cnt = 0; char *currarg; - auto int print_command_info (grub_command_t cmd); - auto int print_command_help (grub_command_t cmd); - - int print_command_info (grub_command_t cmd) + if (argc == 0) { - if ((cmd->prio & GRUB_PRIO_LIST_FLAG_ACTIVE) && - (cmd->flags & GRUB_COMMAND_FLAG_CMDLINE)) - { - struct grub_term_output *term; - const char *summary_translated = _(cmd->summary); - char *command_help; - grub_uint32_t *unicode_command_help; - grub_uint32_t *unicode_last_position; + grub_command_t cmd; + FOR_COMMANDS(cmd) + { + if ((cmd->prio & GRUB_PRIO_LIST_FLAG_ACTIVE) && + (cmd->flags & GRUB_COMMAND_FLAG_CMDLINE)) + { + struct grub_term_output *term; + const char *summary_translated = _(cmd->summary); + char *command_help; + grub_uint32_t *unicode_command_help; + grub_uint32_t *unicode_last_position; - command_help = grub_xasprintf ("%s %s", cmd->name, summary_translated); - if (!command_help) - return 1; + command_help = grub_xasprintf ("%s %s", cmd->name, summary_translated); + if (!command_help) - break; ++ return 1; - grub_utf8_to_ucs4_alloc (command_help, &unicode_command_help, - &unicode_last_position); - FOR_ACTIVE_TERM_OUTPUTS(term) - { - unsigned stringwidth; - grub_uint32_t *unicode_last_screen_position; + grub_utf8_to_ucs4_alloc (command_help, &unicode_command_help, + &unicode_last_position); - + FOR_ACTIVE_TERM_OUTPUTS(term) + { + unsigned stringwidth; + grub_uint32_t *unicode_last_screen_position; - + - unicode_last_screen_position = unicode_command_help; + unicode_last_screen_position = unicode_command_help; - + - stringwidth = 0; + stringwidth = 0; - + - while (unicode_last_screen_position < unicode_last_position && - stringwidth < ((grub_term_width (term) / 2) - 2)) - { - struct grub_unicode_glyph glyph; - unicode_last_screen_position - += grub_unicode_aglomerate_comb (unicode_last_screen_position, - unicode_last_position - - unicode_last_screen_position, - &glyph); + while (unicode_last_screen_position < unicode_last_position && + stringwidth < ((grub_term_width (term) / 2) - 2)) + { ++ struct grub_unicode_glyph glyph; ++ unicode_last_screen_position ++ += grub_unicode_aglomerate_comb (unicode_last_screen_position, ++ unicode_last_position ++ - unicode_last_screen_position, ++ &glyph); + - stringwidth - += grub_term_getcharwidth (term, &glyph); - } + stringwidth - += grub_term_getcharwidth (term, - *unicode_last_screen_position); - unicode_last_screen_position++; ++ += grub_term_getcharwidth (term, &glyph); + } - grub_print_ucs4 (unicode_command_help, - unicode_last_screen_position, 0, 0, term); - if (!(cnt % 2)) - grub_print_spaces (term, grub_term_width (term) / 2 - - stringwidth); - } - - if (cnt % 2) - grub_printf ("\n"); - cnt++; - - grub_free (command_help); - grub_free (unicode_command_help); - } - return 0; - } - - int print_command_help (grub_command_t cmd) - { - if (cmd->prio & GRUB_PRIO_LIST_FLAG_ACTIVE) - { - if (! grub_strncmp (cmd->name, currarg, grub_strlen (currarg))) - { - if (cnt++ > 0) - grub_printf ("\n\n"); - - if (cmd->flags & GRUB_COMMAND_FLAG_EXTCMD) - grub_arg_show_help ((grub_extcmd_t) cmd->data); - else - grub_printf ("%s %s %s\n%s\n", _("Usage:"), cmd->name, _(cmd->summary), - _(cmd->description)); + grub_print_ucs4 (unicode_command_help, - unicode_last_screen_position, term); ++ unicode_last_screen_position, 0, 0, term); + if (!(cnt % 2)) + grub_print_spaces (term, grub_term_width (term) / 2 + - stringwidth); } - } - return 0; - } + - if (argc == 0) - { - grub_command_iterate (print_command_info); + if (cnt % 2) + grub_printf ("\n"); + cnt++; + + grub_free (command_help); + grub_free (unicode_command_help); + } + } if (!(cnt % 2)) grub_printf ("\n"); } diff --cc commands/minicmd.c index 25bda6d23,92d262caf..d71174598 --- a/commands/minicmd.c +++ b/commands/minicmd.c @@@ -301,27 -301,23 +301,23 @@@ grub_mini_cmd_lsmod (struct grub_comman int argc __attribute__ ((unused)), char *argv[] __attribute__ ((unused))) { - auto int print_module (grub_dl_t mod); - - int print_module (grub_dl_t mod) - { - grub_dl_dep_t dep; - - grub_printf ("%s\t%d\t\t", mod->name, mod->ref_count); - for (dep = mod->dep; dep; dep = dep->next) - { - if (dep != mod->dep) - grub_xputs (","); - - grub_printf ("%s", dep->mod->name); - } - grub_xputs ("\n"); - - return 0; - } + grub_dl_t mod; grub_printf ("Name\tRef Count\tDependencies\n"); - grub_dl_iterate (print_module); + FOR_DL_MODULES (mod) + { + grub_dl_dep_t dep; + + grub_printf ("%s\t%d\t\t", mod->name, mod->ref_count); + for (dep = mod->dep; dep; dep = dep->next) + { + if (dep != mod->dep) - grub_putchar (','); ++ grub_xputs (","); + + grub_printf ("%s", dep->mod->name); + } - grub_putchar ('\n'); ++ grub_xputs ("\n"); + } return 0; } diff --cc conf/common.rmk index 3e22678ad,c98060a29..1af14f7fd --- a/conf/common.rmk +++ b/conf/common.rmk @@@ -83,7 -69,7 +69,8 @@@ grub_fstest_SOURCES = gnulib/progname. # For grub-mkfont. ifeq ($(enable_grub_mkfont), yes) bin_UTILITIES += grub-mkfont - grub_mkfont_SOURCES = gnulib/progname.c util/grub-mkfont.c util/misc.c unidata.c -grub_mkfont_SOURCES = gnulib/progname.c util/grub-mkfont.c util/misc.c kern/emu/misc.c ++grub_mkfont_SOURCES = gnulib/progname.c util/grub-mkfont.c util/misc.c \ ++ unidata.c kern/emu/misc.c grub_mkfont_CFLAGS = $(freetype_cflags) grub_mkfont_LDFLAGS = $(freetype_libs) endif @@@ -462,12 -438,12 +439,12 @@@ scsi_mod_CFLAGS = $(COMMON_CFLAGS scsi_mod_LDFLAGS = $(COMMON_LDFLAGS) # Commands. - pkglib_MODULES += minicmd.mod extcmd.mod hello.mod handler.mod \ + pkglib_MODULES += minicmd.mod extcmd.mod hello.mod \ ls.mod cmp.mod cat.mod help.mod search.mod loopback.mod \ configfile.mod echo.mod \ - terminfo.mod test.mod blocklist.mod hexdump.mod \ + test.mod blocklist.mod hexdump.mod \ read.mod sleep.mod loadenv.mod crc.mod parttool.mod \ - msdospart.mod memrw.mod normal.mod sh.mod \ + msdospart.mod memrw.mod normal.mod \ gptsync.mod true.mod probe.mod password.mod \ keystatus.mod @@@ -655,24 -622,15 +627,18 @@@ keystatus_mod_CFLAGS = $(COMMON_CFLAGS keystatus_mod_LDFLAGS = $(COMMON_LDFLAGS) # For normal.mod. +ifneq (, $(FONT_SOURCE)) +normal/charset.c_DEPENDENCIES = widthspec.h +endif normal_mod_SOURCES = normal/main.c normal/cmdline.c normal/dyncmd.c \ - normal/auth.c normal/autofs.c normal/handler.c \ + normal/auth.c normal/autofs.c \ normal/color.c normal/completion.c normal/datetime.c normal/menu.c \ - normal/menu_entry.c normal/menu_text.c \ + normal/menu_entry.c normal/menu_text.c normal/charset.c \ normal/misc.c normal/crypto.c normal/term.c normal/context.c \ - unidata.c - - normal_mod_CFLAGS = $(COMMON_CFLAGS) - normal_mod_LDFLAGS = $(COMMON_LDFLAGS) - - # For sh.mod. - sh_mod_SOURCES = script/main.c script/script.c script/execute.c \ - script/main.c script/script.c script/execute.c \ ++ script/main.c script/script.c script/execute.c unidata.c \ script/function.c script/lexer.c grub_script.tab.c grub_script.yy.c - sh_mod_CFLAGS = $(COMMON_CFLAGS) $(POSIX_CFLAGS) -Wno-error - sh_mod_LDFLAGS = $(COMMON_LDFLAGS) + normal_mod_CFLAGS = $(COMMON_CFLAGS) $(POSIX_CFLAGS) -Wno-error + normal_mod_LDFLAGS = $(COMMON_LDFLAGS) ifneq (, $(FONT_SOURCE)) font/font.c_DEPENDENCIES = ascii.h diff --cc conf/powerpc-ieee1275.rmk index cd08770df,be95b30ba..3ec5ec906 --- a/conf/powerpc-ieee1275.rmk +++ b/conf/powerpc-ieee1275.rmk @@@ -13,10 -13,10 +13,10 @@@ kernel_img_SOURCES = kern/powerpc/ieee1 kern/disk.c kern/dl.c kern/err.c kern/file.c kern/fs.c \ kern/misc.c kern/mm.c kern/term.c \ kern/rescue_parser.c kern/rescue_reader.c \ - kern/list.c kern/handler.c kern/command.c kern/corecmd.c \ + kern/list.c kern/command.c kern/corecmd.c \ kern/ieee1275/init.c \ kern/ieee1275/mmap.c \ - term/ieee1275/ofconsole.c \ + term/ieee1275/ofconsole.c term/terminfo.c term/tparm.c \ kern/ieee1275/openfw.c disk/ieee1275/ofdisk.c \ kern/parser.c kern/partition.c kern/env.c kern/$(target_cpu)/dl.c \ kern/generic/millisleep.c kern/time.c \ diff --cc include/grub/term.h index 9fab96a69,971a8db32..f40d935e4 --- a/include/grub/term.h +++ b/include/grub/term.h @@@ -38,8 -38,7 +38,8 @@@ #include #include #include - #include +#include + #include /* These are used to represent the various color states we use. */ typedef enum @@@ -222,6 -213,14 +222,14 @@@ grub_term_register_input (const char *n } } + static inline void + grub_term_register_input_active (const char *name __attribute__ ((unused)), + grub_term_input_t term) + { - if (! term->init || term->init () == GRUB_ERR_NONE) ++ if (! term->init || term->init (term) == GRUB_ERR_NONE) + grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term)); + } + static inline void grub_term_register_output (const char *name __attribute__ ((unused)), grub_term_output_t term) @@@ -238,6 -237,15 +246,15 @@@ } } + static inline void + grub_term_register_output_active (const char *name __attribute__ ((unused)), + grub_term_output_t term) + { - if (! term->init || term->init () == GRUB_ERR_NONE) ++ if (! term->init || term->init (term) == GRUB_ERR_NONE) + grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs), + GRUB_AS_LIST (term)); + } + static inline void grub_term_unregister_input (grub_term_input_t term) { @@@ -254,12 -262,14 +271,12 @@@ grub_term_unregister_output (grub_term_ GRUB_AS_LIST (term)); } - #define FOR_ACTIVE_TERM_INPUTS(var) for (var = grub_term_inputs; var; var = var->next) - #define FOR_DISABLED_TERM_INPUTS(var) for (var = grub_term_inputs_disabled; var; var = var->next) - #define FOR_ACTIVE_TERM_OUTPUTS(var) for (var = grub_term_outputs; var; var = var->next) - #define FOR_DISABLED_TERM_OUTPUTS(var) for (var = grub_term_outputs_disabled; var; var = var->next) + #define FOR_ACTIVE_TERM_INPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_inputs)) + #define FOR_DISABLED_TERM_INPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_inputs_disabled)) + #define FOR_ACTIVE_TERM_OUTPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_outputs)) + #define FOR_DISABLED_TERM_OUTPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_outputs_disabled)) -void EXPORT_FUNC(grub_putchar) (int c); -void EXPORT_FUNC(grub_putcode) (grub_uint32_t code, - struct grub_term_output *term); +void grub_putcode (grub_uint32_t code, struct grub_term_output *term); int EXPORT_FUNC(grub_getkey) (void); int EXPORT_FUNC(grub_checkkey) (void); int EXPORT_FUNC(grub_getkeystatus) (void); diff --cc normal/main.c index e6b0f729a,7275b6367..710b68d14 --- a/normal/main.c +++ b/normal/main.c @@@ -749,7 -691,4 +715,5 @@@ GRUB_MOD_FINI(normal grub_set_history (0); grub_register_variable_hook ("pager", 0, 0); grub_fs_autoload_hook = 0; - free_handler_list (); - + grub_unregister_command (cmd_clear); } diff --cc normal/menu_entry.c index d4d359066,c23d67d70..238c94ecd --- a/normal/menu_entry.c +++ b/normal/menu_entry.c @@@ -23,9 -23,9 +23,10 @@@ #include #include #include + #include #include #include +#include enum update_mode { diff --cc term/i386/pc/vga_text.c index 9fca56c29,717a7576e..1685b3db0 --- a/term/i386/pc/vga_text.c +++ b/term/i386/pc/vga_text.c @@@ -133,16 -123,16 +125,17 @@@ grub_vga_text_cls (struct grub_term_out } static void -grub_vga_text_setcursor (int on) +grub_vga_text_setcursor (struct grub_term_output *term __attribute__ ((unused)), + int on) { grub_uint8_t old; - grub_outb (CRTC_CURSOR, CRTC_ADDR_PORT); - old = grub_inb (CRTC_DATA_PORT); + old = grub_vga_cr_read (GRUB_VGA_CR_CURSOR_START); if (on) - grub_outb (old & ~CRTC_CURSOR_DISABLE, CRTC_DATA_PORT); + grub_vga_cr_write (old & ~GRUB_VGA_CR_CURSOR_START_DISABLE, + GRUB_VGA_CR_CURSOR_START); else - grub_outb (old | CRTC_CURSOR_DISABLE, CRTC_DATA_PORT); + grub_vga_cr_write (old | GRUB_VGA_CR_CURSOR_START_DISABLE, + GRUB_VGA_CR_CURSOR_START); } static grub_err_t diff --cc util/grub-mkdevicemap.c index c68482af1,db37f99e6..6738f7136 --- a/util/grub-mkdevicemap.c +++ b/util/grub-mkdevicemap.c @@@ -38,6 -39,24 +39,26 @@@ #include "progname.h" -void -grub_putchar (int c) ++void ++grub_xputs_real (const char *str) + { - putchar (c); ++ fputs (str, stdout); + } + ++void (*grub_xputs) (const char *str) = grub_xputs_real; ++ + int + grub_getkey (void) + { + return -1; + } + + void + grub_refresh (void) + { + fflush (stdout); + } + static void make_device_map (const char *device_map, int floppy_disks) { diff --cc util/i386/pc/grub-setup.c index caed2d956,32f1f90e4..9407c5d47 --- a/util/i386/pc/grub-setup.c +++ b/util/i386/pc/grub-setup.c @@@ -57,14 -57,19 +57,21 @@@ static const grub_gpt_part_type_t grub_ #define DEFAULT_BOOT_FILE "boot.img" #define DEFAULT_CORE_FILE "core.img" + #define grub_target_to_host16(x) grub_le_to_cpu16(x) + #define grub_target_to_host32(x) grub_le_to_cpu32(x) + #define grub_target_to_host64(x) grub_le_to_cpu64(x) + #define grub_host_to_target16(x) grub_cpu_to_le16(x) + #define grub_host_to_target32(x) grub_cpu_to_le32(x) + #define grub_host_to_target64(x) grub_cpu_to_le64(x) + -void -grub_putchar (int c) +void +grub_xputs_real (const char *str) { - putchar (c); + fputs (str, stdout); } +void (*grub_xputs) (const char *str) = grub_xputs_real; + int grub_getkey (void) {