gettext: help commands

2009-12-25 Thread Carles Pina i Estany

Hello,

Find attached a patch that gettextizze the output of:
help play
help search
search --help

So, implements gettext in commands/help.c, lib/arg.c, I also did in
normal/dyncmd.c (for the module not found).

This is only the basic implementation, when this is agreed I will
prepare another patch to gettextizze the help of all commands.

I would commit it in this way when someone reviews it. It's quite
straightforward.

Thanks,

-- 
Carles Pina i Estany
http://pinux.info
=== modified file 'ChangeLog'
--- ChangeLog	2009-12-25 00:04:51 +
+++ ChangeLog	2009-12-25 11:41:28 +
@@ -1,5 +1,25 @@
 2009-12-25  Carles Pina i Estany  car...@pina.cat
 
+	* commands/help.c: Include `grub/i18n.h'.
+	(grub_cmd_help): Gettextizze.
+	(GRUB_MOD_INIT): Likewise.
+	* commands/i386/pc/play.c: Include `grub/i18n.h'.
+	(GRUB_MOD_INIT): Gettextizze.
+	* commands/search.c: Include `grub/i18n.h'.
+	(options): Gettextizze.
+	(GRUB_MOD_INIT): Gettextizze.
+	* lib/arg.c: Include `grub/i18n.h'.
+	(help_options): Gettextizze.
+	(find_long): Likewise.
+	(grub_arg_show_help): Likewise.
+	* normal/dyncmd.c: Include `grub/i18n.h'.
+	(read_command_list): Gettextizze.
+	* po/POTFILES: Add `commands/i386/pc/play.c', `commands/search.c',
+	`commands/help.c', `lib/arg.c' and `normal/dyncmd.c'. 
+
+
+2009-12-25  Carles Pina i Estany  car...@pina.cat
+
 	* commands/efi/loadbios.c: Capitalize acronyms, replace `could not' by
 	`couldn't' and `can not' by `cannot'.
 	* commands/i386/pc/drivemap.c: Likewise.

=== modified file 'commands/help.c'
--- commands/help.c	2009-06-10 21:04:23 +
+++ commands/help.c	2009-12-25 11:34:16 +
@@ -21,6 +21,7 @@
 #include grub/misc.h
 #include grub/term.h
 #include grub/extcmd.h
+#include grub/i18n.h
 
 static grub_err_t
 grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
@@ -48,7 +49,7 @@ grub_cmd_help (grub_extcmd_t ext __attri
 		   (desclen  GRUB_TERM_WIDTH / 2 - 1
 			? desclen : GRUB_TERM_WIDTH / 2 - 1));
 
-	  grub_printf (%s%s, description, (cnt++) % 2 ? \n :  );
+	  grub_printf (%s%s, _(description), (cnt++) % 2 ? \n :  );
 	}
   return 0;
 }
@@ -65,8 +66,8 @@ grub_cmd_help (grub_extcmd_t ext __attri
 	  if (cmd-flags  GRUB_COMMAND_FLAG_EXTCMD)
 		grub_arg_show_help ((grub_extcmd_t) cmd-data);
 	  else
-		grub_printf (Usage: %s\n%s\b, cmd-summary,
-			 cmd-description);
+		grub_printf (%s %s\n%s\b, _(Usage:), _(cmd-summary),
+			 _(cmd-description));
 	}
 	}
   return 0;
@@ -94,8 +95,8 @@ GRUB_MOD_INIT(help)
 {
   cmd = grub_register_extcmd (help, grub_cmd_help,
 			  GRUB_COMMAND_FLAG_CMDLINE,
-			  help [PATTERN ...],
-			  Show a help message., 0);
+			  N_(help [PATTERN ...]),
+			  N_(Show a help message.), 0);
 }
 
 GRUB_MOD_FINI(help)

=== modified file 'commands/i386/pc/play.c'
--- commands/i386/pc/play.c	2009-12-21 22:06:04 +
+++ commands/i386/pc/play.c	2009-12-25 11:28:02 +
@@ -27,6 +27,7 @@
 #include grub/machine/time.h
 #include grub/cpu/io.h
 #include grub/command.h
+#include grub/i18n.h
 
 #define BASE_TEMPO 120
 
@@ -207,7 +208,7 @@ static grub_command_t cmd;
 GRUB_MOD_INIT(play)
 {
   cmd = grub_register_command (play, grub_cmd_play,
-			   play FILE, Play a tune.);
+			   N_(play FILE), N_(Play a tune.));
 }
 
 GRUB_MOD_FINI(play)

=== modified file 'commands/search.c'
--- commands/search.c	2009-12-21 22:06:04 +
+++ commands/search.c	2009-12-25 11:28:02 +
@@ -26,14 +26,15 @@
 #include grub/file.h
 #include grub/env.h
 #include grub/extcmd.h
+#include grub/i18n.h
 
 static const struct grub_arg_option options[] =
   {
-{file,		'f', 0, Search devices by a file., 0, 0},
-{label,		'l', 0, Search devices by a filesystem label., 0, 0},
-{fs-uuid,		'u', 0, Search devices by a filesystem UUID., 0, 0},
-{set,		's', GRUB_ARG_OPTION_OPTIONAL, Set a variable to the first device found., VAR, ARG_TYPE_STRING},
-{no-floppy,	'n', 0, Do not probe any floppy drive., 0, 0},
+{file,		'f', 0, N_(Search devices by a file.), 0, 0},
+{label,		'l', 0, N_(Search devices by a filesystem label.), 0, 0},
+{fs-uuid,		'u', 0, N_(Search devices by a filesystem UUID.), 0, 0},
+{set,		's', GRUB_ARG_OPTION_OPTIONAL, N_(Set a variable to the first device found.), VAR, ARG_TYPE_STRING},
+{no-floppy,	'n', 0, N_(Do not probe any floppy drive.), 0, 0},
 {0, 0, 0, 0, 0, 0}
   };
 
@@ -186,11 +187,11 @@ GRUB_MOD_INIT(search)
   cmd =
 grub_register_extcmd (search, grub_cmd_search,
 			  GRUB_COMMAND_FLAG_BOTH,
-			  search [-f|-l|-u|-s|-n] NAME,
-			  Search devices by file, filesystem label or filesystem UUID.
+			  N_(search [-f|-l|-u|-s|-n] NAME),
+			  N_(Search devices by file, filesystem label or filesystem UUID.
 			   If --set is specified, the first device found is
 			   set to a variable. If no variable name is
-			   specified, \root\ is used.,
+			   specified, \root\ is used.),
 			  options);
 }
 

=== modified file 'lib/arg.c'
--- lib/arg.c	

Re: gettext: help commands

2009-12-25 Thread Vladimir 'φ-coder/phcoder' Serbinenko
Carles Pina i Estany wrote:
 Hello,

 Find attached a patch that gettextizze the output of:
 help play
 help search
 search --help

 So, implements gettext in commands/help.c, lib/arg.c, I also did in
 normal/dyncmd.c (for the module not found).

 This is only the basic implementation, when this is agreed I will
 prepare another patch to gettextizze the help of all commands.

 I would commit it in this way when someone reviews it. It's quite
 straightforward.

   

=== modified file 'commands/help.c'
--- commands/help.c2009-06-10 21:04:23 +
+++ commands/help.c2009-12-25 11:34:16 +
 grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
@@ -48,7 +49,7 @@ grub_cmd_help (grub_extcmd_t ext __attri
  (desclen  GRUB_TERM_WIDTH / 2 - 1
   ? desclen : GRUB_TERM_WIDTH / 2 - 1));
 
-grub_printf (%s%s, description, (cnt++) % 2 ? \n :  );
+grub_printf (%s%s, _(description), (cnt++) % 2 ? \n :  );
At this point description is already cut at half of terminal width. You have to 
first translate and then cut the message and not the other way round
   }
   return 0;
 }


 Thanks,

   
 

 ___
 Grub-devel mailing list
 Grub-devel@gnu.org
 http://lists.gnu.org/mailman/listinfo/grub-devel


-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko




signature.asc
Description: OpenPGP digital signature
___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: gettext: help commands

2009-12-25 Thread Carles Pina i Estany

Hi,

On Dec/25/2009, Carles Pina i Estany wrote:

 Find attached a patch that gettextizze the output of:

The patch that I wanted to send is the attached one.

It's the same one but without normal/menu_text.c changed as is not
needed (will maybe be in the future).

-- 
Carles Pina i Estany
http://pinux.info
=== modified file 'ChangeLog'
--- ChangeLog	2009-12-25 00:04:51 +
+++ ChangeLog	2009-12-25 11:45:00 +
@@ -1,5 +1,25 @@
 2009-12-25  Carles Pina i Estany  car...@pina.cat
 
+	* commands/help.c: Include `grub/i18n.h'.
+	(grub_cmd_help): Gettextizze.
+	(GRUB_MOD_INIT): Likewise.
+	* commands/i386/pc/play.c: Include `grub/i18n.h'.
+	(GRUB_MOD_INIT): Gettextizze.
+	* commands/search.c: Include `grub/i18n.h'.
+	(options): Gettextizze.
+	(GRUB_MOD_INIT): Gettextizze.
+	* lib/arg.c: Include `grub/i18n.h'.
+	(help_options): Gettextizze.
+	(find_long): Likewise.
+	(grub_arg_show_help): Likewise.
+	* normal/dyncmd.c: Include `grub/i18n.h'.
+	(read_command_list): Gettextizze.
+	* po/POTFILES: Add `commands/i386/pc/play.c', `commands/search.c',
+	`commands/help.c', `lib/arg.c' and `normal/dyncmd.c'. 
+
+
+2009-12-25  Carles Pina i Estany  car...@pina.cat
+
 	* commands/efi/loadbios.c: Capitalize acronyms, replace `could not' by
 	`couldn't' and `can not' by `cannot'.
 	* commands/i386/pc/drivemap.c: Likewise.

=== modified file 'commands/help.c'
--- commands/help.c	2009-06-10 21:04:23 +
+++ commands/help.c	2009-12-25 11:34:16 +
@@ -21,6 +21,7 @@
 #include grub/misc.h
 #include grub/term.h
 #include grub/extcmd.h
+#include grub/i18n.h
 
 static grub_err_t
 grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
@@ -48,7 +49,7 @@ grub_cmd_help (grub_extcmd_t ext __attri
 		   (desclen  GRUB_TERM_WIDTH / 2 - 1
 			? desclen : GRUB_TERM_WIDTH / 2 - 1));
 
-	  grub_printf (%s%s, description, (cnt++) % 2 ? \n :  );
+	  grub_printf (%s%s, _(description), (cnt++) % 2 ? \n :  );
 	}
   return 0;
 }
@@ -65,8 +66,8 @@ grub_cmd_help (grub_extcmd_t ext __attri
 	  if (cmd-flags  GRUB_COMMAND_FLAG_EXTCMD)
 		grub_arg_show_help ((grub_extcmd_t) cmd-data);
 	  else
-		grub_printf (Usage: %s\n%s\b, cmd-summary,
-			 cmd-description);
+		grub_printf (%s %s\n%s\b, _(Usage:), _(cmd-summary),
+			 _(cmd-description));
 	}
 	}
   return 0;
@@ -94,8 +95,8 @@ GRUB_MOD_INIT(help)
 {
   cmd = grub_register_extcmd (help, grub_cmd_help,
 			  GRUB_COMMAND_FLAG_CMDLINE,
-			  help [PATTERN ...],
-			  Show a help message., 0);
+			  N_(help [PATTERN ...]),
+			  N_(Show a help message.), 0);
 }
 
 GRUB_MOD_FINI(help)

=== modified file 'commands/i386/pc/play.c'
--- commands/i386/pc/play.c	2009-12-21 22:06:04 +
+++ commands/i386/pc/play.c	2009-12-25 11:28:02 +
@@ -27,6 +27,7 @@
 #include grub/machine/time.h
 #include grub/cpu/io.h
 #include grub/command.h
+#include grub/i18n.h
 
 #define BASE_TEMPO 120
 
@@ -207,7 +208,7 @@ static grub_command_t cmd;
 GRUB_MOD_INIT(play)
 {
   cmd = grub_register_command (play, grub_cmd_play,
-			   play FILE, Play a tune.);
+			   N_(play FILE), N_(Play a tune.));
 }
 
 GRUB_MOD_FINI(play)

=== modified file 'commands/search.c'
--- commands/search.c	2009-12-21 22:06:04 +
+++ commands/search.c	2009-12-25 11:28:02 +
@@ -26,14 +26,15 @@
 #include grub/file.h
 #include grub/env.h
 #include grub/extcmd.h
+#include grub/i18n.h
 
 static const struct grub_arg_option options[] =
   {
-{file,		'f', 0, Search devices by a file., 0, 0},
-{label,		'l', 0, Search devices by a filesystem label., 0, 0},
-{fs-uuid,		'u', 0, Search devices by a filesystem UUID., 0, 0},
-{set,		's', GRUB_ARG_OPTION_OPTIONAL, Set a variable to the first device found., VAR, ARG_TYPE_STRING},
-{no-floppy,	'n', 0, Do not probe any floppy drive., 0, 0},
+{file,		'f', 0, N_(Search devices by a file.), 0, 0},
+{label,		'l', 0, N_(Search devices by a filesystem label.), 0, 0},
+{fs-uuid,		'u', 0, N_(Search devices by a filesystem UUID.), 0, 0},
+{set,		's', GRUB_ARG_OPTION_OPTIONAL, N_(Set a variable to the first device found.), VAR, ARG_TYPE_STRING},
+{no-floppy,	'n', 0, N_(Do not probe any floppy drive.), 0, 0},
 {0, 0, 0, 0, 0, 0}
   };
 
@@ -186,11 +187,11 @@ GRUB_MOD_INIT(search)
   cmd =
 grub_register_extcmd (search, grub_cmd_search,
 			  GRUB_COMMAND_FLAG_BOTH,
-			  search [-f|-l|-u|-s|-n] NAME,
-			  Search devices by file, filesystem label or filesystem UUID.
+			  N_(search [-f|-l|-u|-s|-n] NAME),
+			  N_(Search devices by file, filesystem label or filesystem UUID.
 			   If --set is specified, the first device found is
 			   set to a variable. If no variable name is
-			   specified, \root\ is used.,
+			   specified, \root\ is used.),
 			  options);
 }
 

=== modified file 'lib/arg.c'
--- lib/arg.c	2009-12-24 22:53:05 +
+++ lib/arg.c	2009-12-25 11:41:40 +
@@ -22,6 +22,7 @@
 #include grub/err.h
 #include grub/term.h
 #include grub/extcmd.h
+#include grub/i18n.h
 
 

Re: gettext: help commands

2009-12-25 Thread Carles Pina i Estany

Hi,

On Dec/25/2009, Vladimir '??-coder/phcoder' Serbinenko wrote:

 === modified file 'commands/help.c'
 --- commands/help.c  2009-06-10 21:04:23 +
 +++ commands/help.c  2009-12-25 11:34:16 +
  grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
 @@ -48,7 +49,7 @@ grub_cmd_help (grub_extcmd_t ext __attri
 (desclen  GRUB_TERM_WIDTH / 2 - 1
  ? desclen : GRUB_TERM_WIDTH / 2 - 1));
  
 -  grub_printf (%s%s, description, (cnt++) % 2 ? \n :  );
 +  grub_printf (%s%s, _(description), (cnt++) % 2 ? \n :  );
 At this point description is already cut at half of terminal width.
 You have to first translate and then cut the message and not the other
 way round

See attached one.


-- 
Carles Pina i Estany
http://pinux.info
=== modified file 'ChangeLog'
--- ChangeLog	2009-12-25 00:04:51 +
+++ ChangeLog	2009-12-25 11:45:00 +
@@ -1,5 +1,25 @@
 2009-12-25  Carles Pina i Estany  car...@pina.cat
 
+	* commands/help.c: Include `grub/i18n.h'.
+	(grub_cmd_help): Gettextizze.
+	(GRUB_MOD_INIT): Likewise.
+	* commands/i386/pc/play.c: Include `grub/i18n.h'.
+	(GRUB_MOD_INIT): Gettextizze.
+	* commands/search.c: Include `grub/i18n.h'.
+	(options): Gettextizze.
+	(GRUB_MOD_INIT): Gettextizze.
+	* lib/arg.c: Include `grub/i18n.h'.
+	(help_options): Gettextizze.
+	(find_long): Likewise.
+	(grub_arg_show_help): Likewise.
+	* normal/dyncmd.c: Include `grub/i18n.h'.
+	(read_command_list): Gettextizze.
+	* po/POTFILES: Add `commands/i386/pc/play.c', `commands/search.c',
+	`commands/help.c', `lib/arg.c' and `normal/dyncmd.c'. 
+
+
+2009-12-25  Carles Pina i Estany  car...@pina.cat
+
 	* commands/efi/loadbios.c: Capitalize acronyms, replace `could not' by
 	`couldn't' and `can not' by `cannot'.
 	* commands/i386/pc/drivemap.c: Likewise.

=== modified file 'commands/help.c'
--- commands/help.c	2009-06-10 21:04:23 +
+++ commands/help.c	2009-12-25 12:27:57 +
@@ -21,6 +21,7 @@
 #include grub/misc.h
 #include grub/term.h
 #include grub/extcmd.h
+#include grub/i18n.h
 
 static grub_err_t
 grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
@@ -44,7 +45,7 @@ grub_cmd_help (grub_extcmd_t ext __attri
 	 with the description followed by spaces.  */
 	  grub_memset (description, ' ', GRUB_TERM_WIDTH / 2 - 1);
 	  description[GRUB_TERM_WIDTH / 2 - 1] = '\0';
-	  grub_memcpy (description, cmd-summary,
+	  grub_memcpy (description, _(cmd-summary),
 		   (desclen  GRUB_TERM_WIDTH / 2 - 1
 			? desclen : GRUB_TERM_WIDTH / 2 - 1));
 
@@ -65,8 +66,8 @@ grub_cmd_help (grub_extcmd_t ext __attri
 	  if (cmd-flags  GRUB_COMMAND_FLAG_EXTCMD)
 		grub_arg_show_help ((grub_extcmd_t) cmd-data);
 	  else
-		grub_printf (Usage: %s\n%s\b, cmd-summary,
-			 cmd-description);
+		grub_printf (%s %s\n%s\b, _(Usage:), _(cmd-summary),
+			 _(cmd-description));
 	}
 	}
   return 0;
@@ -94,8 +95,8 @@ GRUB_MOD_INIT(help)
 {
   cmd = grub_register_extcmd (help, grub_cmd_help,
 			  GRUB_COMMAND_FLAG_CMDLINE,
-			  help [PATTERN ...],
-			  Show a help message., 0);
+			  N_(help [PATTERN ...]),
+			  N_(Show a help message.), 0);
 }
 
 GRUB_MOD_FINI(help)

=== modified file 'commands/i386/pc/play.c'
--- commands/i386/pc/play.c	2009-12-21 22:06:04 +
+++ commands/i386/pc/play.c	2009-12-25 11:28:02 +
@@ -27,6 +27,7 @@
 #include grub/machine/time.h
 #include grub/cpu/io.h
 #include grub/command.h
+#include grub/i18n.h
 
 #define BASE_TEMPO 120
 
@@ -207,7 +208,7 @@ static grub_command_t cmd;
 GRUB_MOD_INIT(play)
 {
   cmd = grub_register_command (play, grub_cmd_play,
-			   play FILE, Play a tune.);
+			   N_(play FILE), N_(Play a tune.));
 }
 
 GRUB_MOD_FINI(play)

=== modified file 'commands/search.c'
--- commands/search.c	2009-12-21 22:06:04 +
+++ commands/search.c	2009-12-25 11:28:02 +
@@ -26,14 +26,15 @@
 #include grub/file.h
 #include grub/env.h
 #include grub/extcmd.h
+#include grub/i18n.h
 
 static const struct grub_arg_option options[] =
   {
-{file,		'f', 0, Search devices by a file., 0, 0},
-{label,		'l', 0, Search devices by a filesystem label., 0, 0},
-{fs-uuid,		'u', 0, Search devices by a filesystem UUID., 0, 0},
-{set,		's', GRUB_ARG_OPTION_OPTIONAL, Set a variable to the first device found., VAR, ARG_TYPE_STRING},
-{no-floppy,	'n', 0, Do not probe any floppy drive., 0, 0},
+{file,		'f', 0, N_(Search devices by a file.), 0, 0},
+{label,		'l', 0, N_(Search devices by a filesystem label.), 0, 0},
+{fs-uuid,		'u', 0, N_(Search devices by a filesystem UUID.), 0, 0},
+{set,		's', GRUB_ARG_OPTION_OPTIONAL, N_(Set a variable to the first device found.), VAR, ARG_TYPE_STRING},
+{no-floppy,	'n', 0, N_(Do not probe any floppy drive.), 0, 0},
 {0, 0, 0, 0, 0, 0}
   };
 
@@ -186,11 +187,11 @@ GRUB_MOD_INIT(search)
   cmd =
 grub_register_extcmd (search, grub_cmd_search,
 			  GRUB_COMMAND_FLAG_BOTH,
-			  search [-f|-l|-u|-s|-n] NAME,
-			  

Re: gettext: help commands

2009-12-25 Thread Vladimir 'φ-coder/phcoder' Serbinenko
Carles Pina i Estany wrote:
 Hi,

 On Dec/25/2009, Vladimir '??-coder/phcoder' Serbinenko wrote:

   
 === modified file 'commands/help.c'
 --- commands/help.c 2009-06-10 21:04:23 +
 +++ commands/help.c 2009-12-25 11:34:16 +
 grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
 @@ -48,7 +49,7 @@ grub_cmd_help (grub_extcmd_t ext __attri
(desclen  GRUB_TERM_WIDTH / 2 - 1
 ? desclen : GRUB_TERM_WIDTH / 2 - 1));

 - grub_printf (%s%s, description, (cnt++) % 2 ? \n :  );
 + grub_printf (%s%s, _(description), (cnt++) % 2 ? \n :  );
   
 At this point description is already cut at half of terminal width.
 You have to first translate and then cut the message and not the other
 way round
 

 See attached one.

   
Now 'desclen' is out of sync with message
   
 

 ___
 Grub-devel mailing list
 Grub-devel@gnu.org
 http://lists.gnu.org/mailman/listinfo/grub-devel


-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko




signature.asc
Description: OpenPGP digital signature
___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


gettext: lib/arg.c

2009-12-25 Thread Carles Pina i Estany

Hi,

My previous patch touches lib/arg.c, and I would commit that patch but
we should fix something that will happen there.

lib/arg.c does:
  const char *doc = _(opt-doc);
  for (;;)
{
  while (spacing--  0)
grub_putchar (' ');

  while (*doc  *doc != '\n')
grub_putchar (*doc++);
  grub_putchar ('\n');

  if (! *doc)
break;
  doc++;
  spacing = 4 + 20;
}

so, is cutting the string doc using \n, and the after \n inserting spaces.

If the developer or the programmer does't write \n in the correct place
(so the string is too long) it's not correctly formatted on screen.

I wanted to use grub_print_message_indented (I could insert spaces until
margin_left checking the current x position). But if I call from lib/arg.c
grub_print_message_indented it's needed to link fstest with all terminal
stuff. I tried but dependencies goes quite far.

So, I'm thinking to do something like:
  char *doc = _(opt-doc);

  insert_newlines(doc)

  for (;;)
{

}

insert_newlines will insert newlines in the appropiate places. So
developers and translators doesn't need to think about how to format
the message.

Because it's not terminal dependant it will maybe not use all
terminal width in terminals bigger than 80 characters.

How it sounds?

Other approach would be to use grub_print_message_indented, dependencies
will affect mainly fstest (it use lib/arg.c). Or have a dummy
grub_print_message_indented for fstest.

-- 
Carles Pina i Estany
http://pinux.info


___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: gettext: help commands

2009-12-25 Thread Carles Pina i Estany

Hi,

On Dec/25/2009, Vladimir '??-coder/phcoder' Serbinenko wrote:
 
 Now 'desclen' is out of sync with message

(arf, rushing for Christmas lunch :-) )

Now all cmd-summary and cmd-description in commands/help.c are
gettextizzed. I've reviewed lib/arg.c and was fine. 

Thanks Vladimir,

-- 
Carles Pina i Estany
http://pinux.info
=== modified file 'commands/help.c'
--- commands/help.c	2009-06-10 21:04:23 +
+++ commands/help.c	2009-12-25 12:36:54 +
@@ -21,6 +21,7 @@
 #include grub/misc.h
 #include grub/term.h
 #include grub/extcmd.h
+#include grub/i18n.h
 
 static grub_err_t
 grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
@@ -38,13 +39,13 @@ grub_cmd_help (grub_extcmd_t ext __attri
 	  (cmd-flags  GRUB_COMMAND_FLAG_CMDLINE))
 	{
 	  char description[GRUB_TERM_WIDTH / 2];
-	  int desclen = grub_strlen (cmd-summary);
+	  int desclen = grub_strlen (_(cmd-summary));
 
 	  /* Make a string with a length of GRUB_TERM_WIDTH / 2 - 1 filled
 	 with the description followed by spaces.  */
 	  grub_memset (description, ' ', GRUB_TERM_WIDTH / 2 - 1);
 	  description[GRUB_TERM_WIDTH / 2 - 1] = '\0';
-	  grub_memcpy (description, cmd-summary,
+	  grub_memcpy (description, _(cmd-summary),
 		   (desclen  GRUB_TERM_WIDTH / 2 - 1
 			? desclen : GRUB_TERM_WIDTH / 2 - 1));
 
@@ -65,8 +66,8 @@ grub_cmd_help (grub_extcmd_t ext __attri
 	  if (cmd-flags  GRUB_COMMAND_FLAG_EXTCMD)
 		grub_arg_show_help ((grub_extcmd_t) cmd-data);
 	  else
-		grub_printf (Usage: %s\n%s\b, cmd-summary,
-			 cmd-description);
+		grub_printf (%s %s\n%s\b, _(Usage:), _(cmd-summary),
+			 _(cmd-description));
 	}
 	}
   return 0;
@@ -94,8 +95,8 @@ GRUB_MOD_INIT(help)
 {
   cmd = grub_register_extcmd (help, grub_cmd_help,
 			  GRUB_COMMAND_FLAG_CMDLINE,
-			  help [PATTERN ...],
-			  Show a help message., 0);
+			  N_(help [PATTERN ...]),
+			  N_(Show a help message.), 0);
 }
 
 GRUB_MOD_FINI(help)

___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: [RFC] Dynamic device.map

2009-12-25 Thread Felix Zielcke
Am Donnerstag, den 24.12.2009, 22:17 +0100 schrieb Robert Millan:
 On Thu, Dec 10, 2009 at 11:12:58AM +0100, Felix Zielcke wrote:
  Am Donnerstag, den 10.12.2009, 01:55 +0100 schrieb Robert Millan:
   But first we'd need to figure out what we do with the set
 root=xxx
   backward compatibility hack.  Has it been a while long enough that
   we can remove support for GRUB installs that didn't come with UUID
   support? 
  
  Well we still have Arthur Marsh' bug open that search --fs-uuid
 fails
  with right UUID even though ls (hdx,y) shows it.
 
 Uhm ISTR Vladimir fixed this one.

Yes in the meanwhile he commited the fix.

-- 
Felix Zielcke
Proud Debian Maintainer and GNU GRUB developer



___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: execution of update-grub in chroots might fail

2009-12-25 Thread Felix Zielcke
Am Donnerstag, den 24.12.2009, 22:28 +0100 schrieb Robert Millan:
 On Mon, Dec 14, 2009 at 11:56:21AM +, Colin Watson wrote:
  The simplest fix is to add ' [ -e /boot/grub/grub.cfg ]' to the
 test
  in memtest86+;
 
 Uhm should we make this check part of update-grub?  Or even part of
 grub-mkconfig?

I don't think grub-mkconfig should check for that. And if it does then
we should make it optional by adding something like --update as option
to it.
If people of other distributions compile GRUB 2 they should be able to
just use grub-mkconfig directly to create their initial config without
much hassle.

  that is, if the configuration file hasn't been generated
  already, it shouldn't be updated. (This check is in the memtest86+
  postinst in Ubuntu.) This accounts for the OpenVZ problem as well as
 for
  other reasons why GRUB might not actually be being used as a boot
  loader.
  
  You're right that it is suboptimal that every package has to
 implement
  the check itself. My instinct is that the semantics of update-grub
 ought
  to change slightly, so that it really is an *update* - that is, it
  shouldn't by default generate a configuration file if there isn't
 one
  already. It could have a --force option (or better name?) for
  convenience, for use by the grub2 packaging itself, and for use by
 the
  installer. Anything much more complex than that smells of
  overengineering to me.
  
  Note, though, that care would need to be taken to ensure that
  grub-installer is changed in step; it's important to minimise the
  chances of consequential installer brokenness. There's little
 urgency on
  this so we could afford the time for a proper transition. For
 example,
  update-grub could accept but ignore the new option for a while;
 then,
  after the relevant version of grub2 has moved to testing,
 grub-installer
  could be updated to use it; then, at some later point, the default
  semantics of update-grub could change.
  
  If that's too complicated, we could just add an --if-exists option
 or
  something that does what memtest86+ and other similar packages need.
  There are very few packages in this boat, so it may not be worth
 very
  much effort to deal with them.
  
  Robert, Felix, what do you think?
 
 I think it's fine to make this update conditional.  My only concern is
 that
 external packages have a mechanism to add their stuff into grub.cfg
 (this
 was one of the key motivations for initial grub-mkconfig design).
 

In Debian at least they probable all rely that grub-pc etc. is installed
first.
If you have grub2 installed but no config then you probable don't want
that e.g. memtest86+ suddenly creates it.
-- 
Felix Zielcke
Proud Debian Maintainer and GNU GRUB developer



___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: Fix for grub_assert_fail undefined on NetBSD and other platforms

2009-12-25 Thread Felix Zielcke
Am Donnerstag, den 24.12.2009, 22:55 +0100 schrieb Robert Millan:
 On Tue, Dec 22, 2009 at 09:39:07PM +0530, BVK Chaitanya wrote:
  Hi
  
  
  Attached is the patch, which removes use of undefined
 grub_assert_fail
  function for catching bad-type-cast errors, with a better version
  __attribute__((error(msg))) gcc extension.  With this extension,
 gcc
  can give the exact location of the bad type cast at compile time.
 
 Is this really a kind of error we'd like to report at run time?  Sorry
 if
 I'm missing something, but if we need additional code to handle it,
 and it
 was known at compile time, why do we do this?

__attribute__ ((error)) still reports it at compile time just like the
old grub_assert_fail method.
But the advantage is that you can specify the error message instead of
just getting a `ld: unknown symbol grub_assert_fail' error during
linking. And as BVK said above also the exact location where this
happened.

-- 
Felix Zielcke
Proud Debian Maintainer and GNU GRUB developer



___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH] Bug fix in GRUB script word expansion

2009-12-25 Thread BVK Chaitanya
Hi,


This patch fixes a GRUB script bug in expanding (and splitting into
parameters) words like, aaa${foo}bbb, aaabbb ${foo} cccddd, etc.
forms.



thanks,
-- 
bvk.chaitanya
=== modified file 'ChangeLog.scripting'
--- ChangeLog.scripting 2009-12-25 18:16:20 +
+++ ChangeLog.scripting 2009-12-25 12:13:34 +
@@ -1,5 +1,25 @@
 2009-12-25  BVK Chaitanya  bvk.gro...@gmail.com
 
+   * include/grub/script_sh.h (grub_script_arg_type_t): New types
+   added.
+   (grub_script_execute_arglist_to_arg): Function proptotype added.
+   (grub_script_execute_argument_to_string): Prototype is removed.
+   * script/execute.c (grub_script_execute_arglist_to_arg): New
+   function to convert arglist to argv.
+   (grub_script_execute_cmdfor): Updated to make use of arglist to
+   argv conversion function.
+   (grub_script_execute_cmdline): Likewise.
+   (grub_script_execute_menuentry): Likewise.
+   (grub_script_execute_argument_to_string): Removed.
+   * script/function.c (grub_script_function_create): Removed
+   unnecessary reference to removed function
+   grub_script_execute_argument_to_string.
+   * script/lexer.c (grub_script_yylex): Fixed grub_script_arg
+   argument construction.
+   * script/yylex.l: Likewise.
+
+2009-12-25  BVK Chaitanya  bvk.gro...@gmail.com
+
* conf/tests.rmk: Makerules for new unit tests.
* include/grub/script_sh.h: Function prototypes for for statement
functions.

=== modified file 'include/grub/script_sh.h'
--- include/grub/script_sh.h2009-12-25 18:16:20 +
+++ include/grub/script_sh.h2009-12-25 12:13:34 +
@@ -45,8 +45,11 @@
 
 typedef enum
 {
-  GRUB_SCRIPT_ARG_TYPE_STR,
-  GRUB_SCRIPT_ARG_TYPE_VAR
+  GRUB_SCRIPT_ARG_TYPE_VAR,
+  GRUB_SCRIPT_ARG_TYPE_TEXT,
+  GRUB_SCRIPT_ARG_TYPE_DQVAR,
+  GRUB_SCRIPT_ARG_TYPE_DQSTR,
+  GRUB_SCRIPT_ARG_TYPE_SQSTR
 } grub_script_arg_type_t;
 
 /* A part of an argument.  */
@@ -172,6 +175,9 @@
   /* Text of current token.  */
   char *text;
 
+  /* Type of text.  */
+  grub_script_arg_type_t type;
+
   /* Flex scanner.  */
   void *yyscanner;
 
@@ -316,7 +322,7 @@
 int grub_script_function_call (grub_script_function_t func,
   int argc, char **args);
 
-char *
-grub_script_execute_argument_to_string (struct grub_script_arg *arg);
+char **
+grub_script_execute_arglist_to_argv (struct grub_script_arglist *arglist);
 
 #endif /* ! GRUB_NORMAL_PARSER_HEADER */

=== modified file 'script/execute.c'
--- script/execute.c2009-12-25 18:16:20 +
+++ script/execute.c2009-12-25 12:13:34 +
@@ -35,49 +35,132 @@
   return cmd-exec (cmd);
 }
 
-/* Parse ARG and return the textual representation.  Add strings are
-   concatenated and all values of the variables are filled in.  */
-char *
-grub_script_execute_argument_to_string (struct grub_script_arg *arg)
+#define ROUND_UPTO(sz,up) (((sz) + (up) - 1) / (up) *  (up))
+
+/* Expand arguments in ARGLIST into multiple arguments.  */
+char **
+grub_script_execute_arglist_to_argv (struct grub_script_arglist *arglist)
 {
-  int size = 0;
-  char *val;
-  char *chararg;
-  struct grub_script_arg *argi;
-
-  /* First determine the size of the argument.  */
-  for (argi = arg; argi; argi = argi-next)
-{
-  if (argi-type == 1)
-   {
- val = grub_env_get (argi-str);
- if (val)
-   size += grub_strlen (val);
-   }
-  else
-   size += grub_strlen (argi-str);
-}
-
-  /* Create the argument.  */
-  chararg = grub_malloc (size + 1);
-  if (! chararg)
-return 0;
-
-  *chararg = '\0';
-  /* First determine the size of the argument.  */
-  for (argi = arg; argi; argi = argi-next)
-{
-  if (argi-type == 1)
-   {
- val = grub_env_get (argi-str);
- if (val)
-   grub_strcat (chararg, val);
-   }
-  else
-   grub_strcat (chararg, argi-str);
-}
-
-  return chararg;
+  int i;
+  int oom;
+  int argc;
+  char *ptr;
+  char **argv;
+  char *value;
+  struct grub_script_arg *arg;
+
+  auto void push (char *str);
+  void push (char *str)
+  {
+char **ptr;
+
+if (oom)
+  return;
+
+ptr = grub_realloc (argv, ROUND_UPTO (sizeof(char*) * (argc + 1), 32));
+if (!ptr)
+  oom = 1;
+else
+  {
+   ptr[argc++] = str;
+   argv = ptr;
+  }
+  }
+
+  auto char* append (const char *str, grub_size_t nchar);
+  char* append (const char *str, grub_size_t nchar)
+  {
+int len;
+int old;
+char *ptr;
+
+if (oom || !str)
+  return 0;
+
+len = nchar ?: grub_strlen (str);
+old = argv[argc - 1] ? grub_strlen (argv[argc - 1]) : 0;
+ptr = grub_realloc (argv[argc - 1], ROUND_UPTO(old + len + 1, 32));
+
+if (ptr)
+  {
+   grub_strncpy (ptr + old, str, len);
+   ptr[old + len] = '\0';
+  }
+else
+  {
+   oom = 1;
+   grub_free (argv[argc - 1]);
+  }
+argv[argc - 1] = ptr;
+return argv[argc - 1];
+  }
+
+  

Grub is the bootloader used on Win7?

2009-12-25 Thread Renato S . Yamane

​Hi,

I´m a GNU/Linux user, but I have a computer with Windows too (fresh install, 
with NO Linux installed)

Recently, my RAID5 failed, sometimes I get a corrupetd system and I see Windows 
loading GRUB!

Anyone now if Windows7 is using Grub as default bootloader (because I don´t 
believe that Grub is installed on my BIOS)?

- This is the first message error:
http://img31.imageshack.us/img31/7215/img0227s.jpg

- When I press Enter I see this:
http://img10.imageshack.us/img10/5285/img0225jm.jpg

- And this is the commands available:
http://img85.imageshack.us/img85/7056/img0229w.jpg

Best regards and Merry Christimas!
Renato S. Yamane


___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: Grub is the bootloader used on Win7?

2009-12-25 Thread Felix Zielcke
Am Freitag, den 25.12.2009, 19:15 -0200 schrieb Renato S.Yamane:
 ​Hi,
 
 I´m a GNU/Linux user, but I have a computer with Windows too (fresh
 install, with NO Linux installed)
 
 Recently, my RAID5 failed, sometimes I get a corrupetd system and I
 see Windows loading GRUB!
 
 Anyone now if Windows7 is using Grub as default bootloader (because I
 don´t believe that Grub is installed on my BIOS)?
 
 - This is the first message error:
 http://img31.imageshack.us/img31/7215/img0227s.jpg
 
 - When I press Enter I see this:
 http://img10.imageshack.us/img10/5285/img0225jm.jpg
 
 - And this is the commands available:
 http://img85.imageshack.us/img85/7056/img0229w.jpg
 
 Best regards and Merry Christimas!
 Renato S. Yamane

Official Windows 7 from Microsoft unmodified, i.e. not some preinstalled
OEM Version does clearly not use GRUB4DOS nor plain GRUB Legacy nor GRUB
2.
They still use bootmgr which they introduced with Vista, which is
basically though the old ntldr from NT4/2000/XP just a bit modified.

GRUB4DOS by the way is just a fork of GRUB and not made by us neither
supported on this list.

-- 
Felix Zielcke
Proud Debian Maintainer and GNU GRUB developer



___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH] While and until loops support to GRUB script

2009-12-25 Thread BVK Chaitanya
Hi,


Attached patch adds while and until commands support to GRUB script.
It is also available in people/bvk/while-loop-support branch.   This
doesn't have any unit tests yet -- i am still thinking of how to break
out of the loop, after few iterations.  Also, i am not sure how to
handle Ctrl-C to break out of the loop, if at all we want to support
it :-(



thanks,
-- 
bvk.chaitanya
=== modified file 'ChangeLog.scripting'
--- ChangeLog.scripting 2009-12-26 04:07:41 +
+++ ChangeLog.scripting 2009-12-26 05:05:37 +
@@ -1,3 +1,17 @@
+2009-12-26  BVK Chaitanya  bvk.gro...@gmail.com
+
+   * include/grub/script_sh.h: New function prototypes for
+   grub_script_create_cmdwhile and grub_script_execute_cmdwhile.
+   * script/parser.y (whilecmd): New grammar rule for while
+   command.
+   (untilcmd): New grammar rule for until command.
+   * script/script.c (grub_script_create_cmdwhile): Creates a
+   while/until command object.
+   * script/execute.c (grub_script_execute_cmdwhile): Executes a
+   while/until command object.
+   * util/grub-script-check.c (grub_script_execute_cmdwhile): Dummy
+   stub for syntax checking while/until statements.
+
 2009-12-25  BVK Chaitanya  bvk.gro...@gmail.com
 
* include/grub/script_sh.h (grub_script_arg_type_t): New types

=== modified file 'include/grub/script_sh.h'
--- include/grub/script_sh.h2009-12-26 04:07:41 +
+++ include/grub/script_sh.h2009-12-26 04:51:55 +
@@ -121,6 +121,21 @@
   struct grub_script_cmd *list;
 };
 
+/* A while/until command.  */
+struct grub_script_cmdwhile
+{
+  struct grub_script_cmd cmd;
+
+  /* The command list used as condition.  */
+  struct grub_script_cmd *cond;
+
+  /* The command list executed in each loop.  */
+  struct grub_script_cmd *list;
+
+  /* The flag to indicate this as until loop.  */
+  int until;
+};
+
 /* A menu entry generate statement.  */
 struct grub_script_cmd_menuentry
 {
@@ -236,6 +251,12 @@
   struct grub_script_cmd *list);
 
 struct grub_script_cmd *
+grub_script_create_cmdwhile (struct grub_parser_param *state,
+struct grub_script_cmd *cond,
+struct grub_script_cmd *list,
+int is_an_until_loop);
+
+struct grub_script_cmd *
 grub_script_create_cmdmenu (struct grub_parser_param *state,
struct grub_script_arglist *arglist,
char *sourcecode,
@@ -284,6 +305,7 @@
 grub_err_t grub_script_execute_cmdblock (struct grub_script_cmd *cmd);
 grub_err_t grub_script_execute_cmdif (struct grub_script_cmd *cmd);
 grub_err_t grub_script_execute_cmdfor (struct grub_script_cmd *cmd);
+grub_err_t grub_script_execute_cmdwhile (struct grub_script_cmd *cmd);
 grub_err_t grub_script_execute_menuentry (struct grub_script_cmd *cmd);
 
 /* Execute any GRUB pre-parsed command or script.  */

=== modified file 'script/execute.c'
--- script/execute.c2009-12-26 04:07:41 +
+++ script/execute.c2009-12-26 04:45:21 +
@@ -296,6 +296,26 @@
   return result;
 }
 
+/* Execute a while or until command.  */
+grub_err_t
+grub_script_execute_cmdwhile (struct grub_script_cmd *cmd)
+{
+  int cond;
+  int result;
+  struct grub_script_cmdwhile *cmdwhile = (struct grub_script_cmdwhile *) cmd;
+
+  result = 0;
+  do {
+cond = grub_script_execute_cmd (cmdwhile-cond);
+if ((cmdwhile-until  !cond) || (!cmdwhile-until  cond))
+  break;
+
+result = grub_script_execute_cmd (cmdwhile-list);
+  } while (1); /* XXX Put a check for ^C here */
+
+  return result;
+}
+
 /* Execute the menu entry generate statement.  */
 grub_err_t
 grub_script_execute_menuentry (struct grub_script_cmd *cmd)

=== modified file 'script/parser.y'
--- script/parser.y 2009-12-26 03:51:24 +
+++ script/parser.y 2009-12-26 04:26:28 +
@@ -76,8 +76,9 @@
 %token arg GRUB_PARSER_TOKEN_WORD  word
 
 %type arglist word argument arguments0 arguments1
-%type cmd script_init script grubcmd ifcmd forcmd command
-%type cmd commands1 menuentry statement
+%type cmd script_init script
+%type cmd grubcmd ifcmd forcmd whilecmd untilcmd
+%type cmd command commands1 menuentry statement
 
 %pure-parser
 %error-verbose
@@ -179,9 +180,11 @@
 ;
 
 /* A single command.  */
-command: grubcmd { $$ = $1; }
-   | ifcmd   { $$ = $1; }
-   | forcmd  { $$ = $1; }
+command: grubcmd  { $$ = $1; }
+   | ifcmd{ $$ = $1; }
+   | forcmd   { $$ = $1; }
+   | whilecmd { $$ = $1; }
+   | untilcmd { $$ = $1; }
 ;
 
 /* A list of commands. */
@@ -261,3 +264,25 @@
  grub_script_lexer_deref (state-lexerstate);
}
 ;
+
+whilecmd: while
+  {
+   grub_script_lexer_ref (state-lexerstate);
+  }
+  commands1 delimiters1 do commands1 delimiters1 done
+ {
+   $$ = grub_script_create_cmdwhile (state, $3, $6, 0);
+   grub_script_lexer_deref (state-lexerstate);
+ }

Re: Grub is the bootloader used on Win7?

2009-12-25 Thread richardvo...@gmail.com
On Fri, Dec 25, 2009 at 3:21 PM, Felix Zielcke fziel...@z-51.de wrote:
 Am Freitag, den 25.12.2009, 19:15 -0200 schrieb Renato S.Yamane:
 Hi,

 I´m a GNU/Linux user, but I have a computer with Windows too (fresh
 install, with NO Linux installed)

 Recently, my RAID5 failed, sometimes I get a corrupetd system and I
 see Windows loading GRUB!

 Anyone now if Windows7 is using Grub as default bootloader (because I
 don´t believe that Grub is installed on my BIOS)?

 - This is the first message error:
 http://img31.imageshack.us/img31/7215/img0227s.jpg

 - When I press Enter I see this:
 http://img10.imageshack.us/img10/5285/img0225jm.jpg

 - And this is the commands available:
 http://img85.imageshack.us/img85/7056/img0229w.jpg

 Best regards and Merry Christimas!
 Renato S. Yamane

 Official Windows 7 from Microsoft unmodified, i.e. not some preinstalled
 OEM Version does clearly not use GRUB4DOS nor plain GRUB Legacy nor GRUB
 2.
 They still use bootmgr which they introduced with Vista, which is
 basically though the old ntldr from NT4/2000/XP just a bit modified.

SLIC is part of the mechanism Windows (many versions) uses to volume
license to OEMs and enable OEM recovery disks which only work on a
particular brand or model of computer.  The SLIC is supposed to be
included in the system BIOS by the OEM... but software pirates
sometimes patch the SLIC into the BIOS or use a hotpatch program to
load it before booting into Windows (Windows can't tell whether the
SLIC came legit from an OEM BIOS or from a user hack).  It looks like
this system is running an illegal copy of Windows, or at the very
least improperly activated.  Since Windows 7 was released only in
October, there should still be time to get a refund from the company
who sold you the fake copy of Windows, the Microsoft Anti-piracy
hotline would probably be helpful in forcing the company to provide
you with a legitimate copy.

http://www.microsoft.com/piracy/reporting.mspx


___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel