Re: Fwd: Your contributions to grub.enbug.org
Yes, I do agree. On Mar/31/2011, Vladimir '??-coder/phcoder' Serbinenko wrote: Sorry, Carles. Forgot to add you. Original Message Subject: Your contributions to grub.enbug.org Date: Thu, 31 Mar 2011 21:17:10 +0200 From: Vladimir '??-coder/phcoder' Serbinenko phco...@gmail.com To: Yoshinori K. Okuji ok...@gnu.org, Felix Zielcke fziel...@z-51.de, Robert Millan r...@gnu.org, plr.vinc...@gmail.com, ch...@nic.fi, Colin Watson cjwat...@debian.org, Lubomir Rintel lkund...@v3.sk, Yves Blusseau bluss...@zetam.org, Colin D Bennett co...@gibibit.com, Marco Gerards mgera...@xs4all.nl, Grégoire Sutre gregoire.su...@gmail.com CC: The development of GRUB 2 grub-devel@gnu.org Hello, when discussing after the temporary wiki problems it was decided that it would be better to migrate the information from wiki into the manual and developper manual where legal reasons permit. You have contributed to the wiki, would you agree to consider that your contributor agreement covers wiki as well? -- Regards Vladimir '??-coder/phcoder' Serbinenko ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: New translation template for grub?
Hi, Lasts months I've not been involved in Grub devel (I hope to come back soon or later, I follow some things in the list, etc.). Anyway, I could prepare a template in some weeks time. Or maybe somebody else wants to do (I injured a wrist and typing with one hand is not so funny :-/ ) Cheers, On Dec/19/2010, Aron Xu wrote: Hello, I recently read there are ~270 new strings appear in grub's template, so will there be a new template for translators? or it is too early because the strings is still unstable? -- Regards, Aron Xu -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: Plans on 1.99 release
Hello, On Aug/25/2010, Vladimir '??-coder/phcoder' Serbinenko wrote: Hello, all. 1.98 was released about half a year ago and it means time is to release 1.99 soon. There are few patches around which would be pity if they aren't included in 1.99. Like: 3) Keyboard layouts and related USB improvements Maybe I've missed something. When I did it some months ago was working fine, but we had some design issue (I think that Vladimir wanted to change something, I don't remember if I changed or I didn't). In any case: if nobody has done anything after that, I'll try to catchup and make the required changes. Probably more news soon. -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: gnulib argp
Hi, On Jul/28/2010, Vladimir '??-coder/phcoder' Serbinenko wrote: On 07/24/2010 12:59 AM, Carles Pina i Estany wrote: Hello, Some time ago we talked about importing argp (to make it easier to add gettext support for the --help strings): http://lists.gnu.org/archive/html/grub-devel/2010-03/msg00100.html I see that Vladimir imported gnulib argp module in revno 2282, so should be ready to use in Grub. Colin showed an example: http://lists.gnu.org/archive/html/grub-devel/2010-03/msg00109.html http://bazaar.launchpad.net/~cjwatson/man-db/trunk/annotate/head%3A/src/lexgrog_test.c Any other thoughts about that? I can implement it in some Grub utility to see how it goes. Actually I thought that Vladimir did but I cannot find it. Cheers, http://lists.gnu.org/archive/html/grub-devel/2010-04/msg00025.html ah yes, I saw that mail. Does someone know about argp? I haven't used before, so I don't consider myself with familiar with argp. -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: escape strings in grub.cfg
Hi, On Apr/13/2010, Colin Watson wrote: On Mon, Apr 12, 2010 at 01:09:06AM +0100, Colin Watson wrote: With my suggestion, I'd recommend: gettext_quoted () { gettext $@ | sed s/'/'''/g } ... and then make sure it's enclosed in '' rather than wherever it's used (or modify the sed to put single-quotes at the start and end, if that works out neater). I've gone ahead and committed a patch based on this to trunk, and I'll backport it to Ubuntu Lucid shortly as well. Testing welcome! thanks Colin, I'll do some tests as well. -- 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 util
Hello, On Mar/28/2010, Vladimir '??-coder/phcoder' Serbinenko wrote: Carles Pina i Estany wrote: b) Makes the alignment more difficult Why not just do like -h, --help%s\n -V, --version %s\n -v, --verbose %s\n, _(display this message and exit), _ (print version information and exit), _(print verbose messages) My reasons for argp: a) if someone/something else can take care of counting how many spaces before the short options, to write the , and space and the long option, etc. then is something that we don't need to think and do. Good for consistency between Grub programs and other utilities b) to not have some presentation things in Grub code (spaces, tabs, etc.) (main one:) c) using above way is very easy to do mistakes and swap the description and the command of some option, let's say, updating things OR options that depends of the platform/compiler options. It needs two ifdef in two places instead of only one in argp and more clear, since the argp structure is like: /* The options we understand. */ static struct argp_option options[] = { {verbose, 'v', 0, 0, Produce verbose output }, {quiet,'q', 0, 0, Don't produce any output }, All my reasons are valid if the implementation in Grub doesn't have special problems, else I would re-consider... Probably I'm forgetting some more positive things and missing some negative ones. Cheers, -- 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 util
Hi, On Mar/27/2010, Jordi Mallach wrote: On Sat, Mar 27, 2010 at 12:54:16AM +, Carles Pina i Estany wrote: According to gettext manual usage messages must be internationalised on per-option basis to allow reuse of e.g. --help desciption and to avoid the whole big message to be marked as fuzzy if only one option changes. I'm surprised, specially because if I get the gettext project as a reference: http://git.savannah.gnu.org/cgit/gettext.git/tree/gettext-runtime/src/gettext.c?id=c81a5234a673f6fbc0f8b7ea8f18ef73021b0a2e#n252 They are not doing. Other projects that I can remember where my LUG has done things (e.g. tar) is not done in this way. I don't have any probem to change in Grub, I just wonder if people is expecting it :-/ I'm adding Jordi Mallach to the CC Whether gettext itself is doing it or not, I'll stick to my experience. As a translator, I am *really* fed up of trying to fish in a huge help output to find a tiny change that made the whole string fuzzy and so on. These changes doesn't happen often This is now less of a problem with the tools that support showing the previous string (#|), but it's a huge pain nevertheless. If you want to make translator's life easier, I'd totally go with per option messages. If alignment is a problem (how?), I guess translation comments could be useful to describe how the translated string should look like. I assume you mean: --help Show this help string. --eggs Get two eggs from the fridge, crack them and put them on hot olive oil. It'd be difficult to align Show with Get. I'd say that this depends a lot on the editor you use. Emacs at least makes it easy to calculate if you got it right or wrong. I'm not convinced to change it (yet :-) ). gettext manual says: Translatable strings should be limited to one paragraph; don't let a single message be longer ***than ten lines.*** The reason is that when the translatable string changes, the translator is faced with the task [...] ( http://www.gnu.org/software/gettext/manual/gettext.html ) I have not seen any program (again, yet, maybe Grub will be the first one) to split the messages in this way. Emacs helps to calculate the alignment, but other programs helps to compare the current and the previous message. So the gettext manual is maybe a bit outdated. Plus, these messages in Grub doesn't change often. 10 lines is reasonable in most cases. So my concerns: a) It change a common practise (even when it's not the best one). Translators expects the way that it has been done until now, and I would like that somebody that it's not Grub (small i18n project) starts the change b) Makes the alignment more difficult c) Makes the code a bit less clear Comment: sadly our grub.po already has someo of these long messages. Would you change it and force the translators to change? Or have the Grub domain with some long strings as short strings? Maybe Colin has things to say too. If next messages goes to the same direction (splitting) I'll propose a way to split some non-gettexted message in Grub and then apply the same to the other ones. (Mmm... a nice start would be to split the very-repeated: -h, --helpdisplay this message and exit\n -V, --version print version information and exit\n -v, --verbose print verbose messages\n \n Report bugs to %s.\n In different sentences for all messsages. ) Cheers, -- 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 util
Hello, On Mar/26/2010, Vladimir '??-coder/phcoder' Serbinenko wrote: Carles Pina i Estany wrote: Hello, Last January I asked for ok to commit this to trunk: http://lists.gnu.org/archive/html/grub-devel/2010-01/msg00373.html I've redone the patch (some offsets, Changelog, I removed the translation of two lines talking about glyphs that we said that was not needed I think). See the attached patch. Do I commit? According to gettext manual usage messages must be internationalised on per-option basis to allow reuse of e.g. --help desciption and to avoid the whole big message to be marked as fuzzy if only one option changes. I'm surprised, specially because if I get the gettext project as a reference: http://git.savannah.gnu.org/cgit/gettext.git/tree/gettext-runtime/src/gettext.c?id=c81a5234a673f6fbc0f8b7ea8f18ef73021b0a2e#n252 They are not doing. Other projects that I can remember where my LUG has done things (e.g. tar) is not done in this way. I don't have any probem to change in Grub, I just wonder if people is expecting it :-/ I'm adding Jordi Mallach to the CC Another problem is unclear or ayabtu sentences. Not enough pathname is surely one of them. Can a native English speaker review this part? I'll try to review it. Have you spotted some other one? Cheers, -- 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 util
Hi, On Mar/27/2010, Carles Pina i Estany wrote: According to gettext manual usage messages must be internationalised on per-option basis to allow reuse of e.g. --help desciption and to avoid the whole big message to be marked as fuzzy if only one option changes. I'm surprised, specially because if I get the gettext project as a reference: http://git.savannah.gnu.org/cgit/gettext.git/tree/gettext-runtime/src/gettext.c?id=c81a5234a673f6fbc0f8b7ea8f18ef73021b0a2e#n252 They are not doing. Other projects that I can remember where my LUG has done things (e.g. tar) is not done in this way. not doing it has another problem: alignment. Certainly, not doing it has the problem that you have spotted (changing one option will mark everything has fuzzy). Just I wanted to point to it. -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] Fix locale installation
Hello, On Mar/19/2010, Colin Watson wrote: (cpina, if you're reading, I'd particularly appreciate your review.) Here I am As far as I can see, locale installation is just wrong right now. I cannot test it easily now. I'll comment the new thing forgetting about the old one (doesn't look right) # Copy gettext files mkdir -p ${grubdir}/locale/ -for file in ${grubdir}/locale/*.mo ${pkglibdir}/locale/*.mo; do -if test -f $file; then -cp -f $file ${grubdir}/locale/ +for dir in ${localedir}/*; do +if test -f $dir/LC_MESSAGES/grub.mo; then +cp -f $dir/LC_MESSAGES/grub.mo ${grubdir}/locale/${dir##*/}.mo fi done (I'll use shell variables in a bit on my own way) AFAIK the files are in po/$lang.{po,mo}, right? (at least in my system without using another directory for the building, I need to look in the other issue soon) I thought that make install was copying from po/$lang.mo to /usr/share/locale/$lang/LC_MESSAGES/grub.mo, but you are copying already from some structure in $localedir/LC_MESSAGES/grub.mo. What am I missing? It has been a while that I have not done these things, so sorry to be more an askwer than answerer. -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] Fix locale installation
Hello, On Mar/19/2010, Colin Watson wrote: On Fri, Mar 19, 2010 at 08:35:23PM +, Carles Pina i Estany wrote: On Mar/19/2010, Colin Watson wrote: # Copy gettext files mkdir -p ${grubdir}/locale/ -for file in ${grubdir}/locale/*.mo ${pkglibdir}/locale/*.mo; do -if test -f $file; then -cp -f $file ${grubdir}/locale/ +for dir in ${localedir}/*; do +if test -f $dir/LC_MESSAGES/grub.mo; then +cp -f $dir/LC_MESSAGES/grub.mo ${grubdir}/locale/${dir##*/}.mo fi done (I'll use shell variables in a bit on my own way) AFAIK the files are in po/$lang.{po,mo}, right? (at least in my system without using another directory for the building, I need to look in the other issue soon) In the source, they live in po/$lang.po and po/$lang.mo. However, when you run 'make install', they end up in $datadir/locale/$lang/LC_MESSAGES/grub.mo. grub-install should be looking at the paths used by 'make install', rather than the paths in the source tree which generally won't be accessible. ahh, yeap, I confused grub-install and make install I thought that make install was copying from po/$lang.mo to /usr/share/locale/$lang/LC_MESSAGES/grub.mo, but you are copying already from some structure in $localedir/LC_MESSAGES/grub.mo. What am I missing? You just misread my code slightly, I think. I'm actually copying from I mixed grub-install/make install and what you was doing there... $localedir/*/LC_MESSAGES/grub.mo. My code will copy (e.g.) /usr/share/locale/es/LC_MESSAGES/grub.mo to /boot/grub/locale/es.mo. This seems better than creating lots of subdirectories of /boot/grub/locale/. Yeap, in that case you are right and the code looks fine :-) -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
keyboard layouts
Hello, I have been one month and something without doing lot of Grub things. I think that last time that I did something was going/coming from Fosdem :-/ Hopefully soon I can finish the keyboard layouts. See my branch: sftp://cp...@bzr.savannah.gnu.org/srv/bzr/grub/people/cpina/keyboard_layouts/ Or my attached patch. Right now (and this needs a change) the modules at_keyboard and usb_keyboard doesn't need the at_keyboard_layouts and usb_keyboard_layouts (they have the default layout hardcoded). If the user loads usb_keyboard_layouts, usb_keyboard gets loaded (same with AT). Vladimir suggested, to simplify (usb_keyboard_layouts and at_keyboard_layouts are mainly the same with some defines) that usb_keyboard should depend on keyboard_layouts (generic) and at_keyboard should depen on keyboard_layouts (generic as well). Vladimir: is it what you suggested? Was some time ago... I didn't like a lot because in some circumstancies maybe we don't want layouts at all (some users, environments, etc.) Vladimir liked (if I remember correctly) to avoid having two modules (instead of only one). I have the feeling that I'm biased and I've ate some vladimir reason :-/ I'll do the changes when we will agree. Cheers, -- Carles Pina i Estany http://pinux.info === added file 'ChangeLog.keyboard_layouts' --- ChangeLog.keyboard_layouts 1970-01-01 00:00:00 + +++ ChangeLog.keyboard_layouts 2010-02-13 23:49:34 + @@ -0,0 +1,31 @@ +2010-01-18 Carles Pina i Estany car...@pina.cat + + Adds keyboard layouts support (AT and USB) + + * conf/common.rmk (bin_UTILITIES): Add grub-mklayouts rules. + (pkglib_MODULES): Add module `at_keyboard_layouts.mod' and + `usb_keyboard_layouts.mod'. + * include/grub/at_keyboard.h: Include `keyboard.h'. New EXPORT_VAR + `grub_keyboard_map'. + * include/grub/keyboard.h: New file. + * include/grub/keyboard_layouts.h: New file. + * include/grub/term.h: Move macros from here ... + * include/grub/keys.h: ... to here. New file. + * include/grub/usb_keyboard.h: New file. + * keyboard_layouts/keyboard_layouts.c: New file. + * keyboard_layouts/at_keyboard_layouts.c: New file. + * keyboard_layouts/usb_keyboard_layouts.c: New file. + * term/at_keyboard.c: Include `grub/mm.h'. + (grub_at_keyboard_map): Declare. + (keyboard_map_normal): Renamed from keyboard_map. + (grub_at_keyboard_getkey_noblock): Use `grub_keyboard_map' instead of + `keyboard_map' and `keyboard_map_shift'. + (GRUB_MOD_INIT): Initialise `grub_at_keyboard_map'. + * term/usb_keyboard.c: Include `grub/mm.h' and + `grub/usb_keyboard.h'. + (grub_usb_keyboard_map): Declare. + (keyboard_map_normal): Renamed from keyboard_map. + (grub_usb_keyboard_checkkey): Use `keyboard_map_normal' instead of + `keyboard_map'. + (GRUB_MOD_INIT): Initialise `grub_usb_keyboard_map'. + * util/grub-mklayouts.c: New file. === modified file 'conf/common.rmk' --- conf/common.rmk 2010-03-14 16:50:55 + +++ conf/common.rmk 2010-03-19 23:20:58 + @@ -91,6 +91,10 @@ endif bin_UTILITIES += grub-mkrelpath grub_mkrelpath_SOURCES = gnulib/progname.c util/grub-mkrelpath.c util/misc.c +# For grub-mklayouts. +bin_UTILITIES += grub-mklayouts +grub_mklayouts_SOURCES = gnulib/progname.c util/grub-mklayouts.c util/misc.c + bin_UTILITIES += grub-bin2h grub_bin2h_SOURCES = gnulib/progname.c util/bin2h.c @@ -131,6 +135,18 @@ grub_script.tab.c grub_script.tab.h: scr $(YACC) -d -p grub_script_yy -b grub_script $(srcdir)/script/parser.y DISTCLEANFILES += grub_script.tab.c grub_script.tab.h +# For at_keyboard_layouts.mod +pkglib_MODULES += at_keyboard_layouts.mod +at_keyboard_layouts_mod_SOURCES = keyboard_layouts/at_keyboard_layouts.c +at_keyboard_layouts_mod_CFLAGS = $(COMMON_CFLAGS) +at_keyboard_layouts_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For usb_keyboard_layouts.mod +pkglib_MODULES += usb_keyboard_layouts.mod +usb_keyboard_layouts_mod_SOURCES = keyboard_layouts/usb_keyboard_layouts.c +usb_keyboard_layouts_mod_CFLAGS = $(COMMON_CFLAGS) +usb_keyboard_layouts_mod_LDFLAGS = $(COMMON_LDFLAGS) + # For grub-script-check. grub_script_check_init.lst: geninit.sh $(filter-out grub_script_check_init.c,$(grub_script_check_SOURCES)) rm -f $@; grep GRUB_MOD_INIT $(filter %.c,$^) /dev/null $@ === modified file 'include/grub/at_keyboard.h' --- include/grub/at_keyboard.h 2009-12-25 22:29:47 + +++ include/grub/at_keyboard.h 2010-02-13 23:05:39 + @@ -19,6 +19,10 @@ #ifndef GRUB_AT_KEYBOARD_HEADER #define GRUB_AT_KEYBOARD_HEADER 1 +#include keyboard.h + +extern struct grub_keyboard_map_s *EXPORT_VAR(grub_at_keyboard_map); + #define SHIFT_L 0x2a #define SHIFT_R 0x36 #define CTRL 0x1d === added file 'include/grub/keyboard.h' --- include/grub/keyboard.h 1970-01-01 00:00:00 + +++ include/grub/keyboard.h 2010-02-13 23:29:48 + @@ -0,0 +1,28 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2010 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms
gettext util
Hello, Last January I asked for ok to commit this to trunk: http://lists.gnu.org/archive/html/grub-devel/2010-01/msg00373.html I've redone the patch (some offsets, Changelog, I removed the translation of two lines talking about glyphs that we said that was not needed I think). See the attached patch. Do I commit? I cannot remember if with this patch was absolutely everything gettextizzed in utils, I'll review when it's done. I have the feeling that I left something that may require some discussion. Thanks, -- Carles Pina i Estany http://pinux.info === modified file 'ChangeLog' --- ChangeLog 2010-03-19 11:28:05 + +++ ChangeLog 2010-03-19 23:53:38 + @@ -1,3 +1,19 @@ +2010-03-19 Carles Pina i Estany car...@pina.cat + + * util/grub-editenv.c: Gettextizze mainly all user interface strings + excepting grub_util_info or grub_util_error. + * util/grub-emu.c: Likewise. + * util/grub-fstest.c: Likewise. + * util/grub-macho2img.c: Likewise. + * util/grub-mkdevicemap.c: Likewise. + * util/grub-mkfont.c: Likewise. + * util/grub-mkpasswd-pbkdf2.c: Likewise. + * util/grub-mkrelpath.c: Likewise. + * util/grub-pe2elf.c: Likewise. + * util/grub-probe.c: Likewise. + * util/grub-script-check.c: Likewise. + * po/POTFILES: Add gettextizzed files. + 2010-03-19 Colin Watson cjwat...@ubuntu.com * .bzrignore: Add gentrigtables, grub-script-check, === modified file 'po/POTFILES' --- po/POTFILES 2010-01-21 08:04:49 + +++ po/POTFILES 2010-03-19 23:46:01 + @@ -77,5 +77,17 @@ normal/misc.c term/serial.c +util/grub-editenv.c +util/grub-emu.c +util/grub-fstest.c +util/grub-macho2img.c +util/grub-mkdevicemap.c +util/grub-mkfont.c +util/grub-mkpasswd-pbkdf2.c util/grub-mkrawimage.c +util/grub-mkrelpath.c +util/grub-pe2elf.c +util/grub-probe.c +util/grub-probe.c +util/grub-script-check.c util/i386/pc/grub-setup.c === modified file 'util/grub-editenv.c' --- util/grub-editenv.c 2010-01-16 00:39:14 + +++ util/grub-editenv.c 2010-03-19 23:46:01 + @@ -69,9 +69,9 @@ static void usage (int status) { if (status) -fprintf (stderr, Try `%s --help' for more information.\n, program_name); +fprintf (stderr, _(Try `%s --help' for more information.\n), program_name); else -printf (\ +printf (_(\ Usage: %s [OPTIONS] [FILENAME] COMMAND\n\ \n\ Tool to edit environment block.\n\ @@ -87,7 +87,7 @@ Tool to edit environment block.\n\ \n\ If not given explicitly, FILENAME defaults to %s.\n\ \n\ -Report bugs to %s.\n, +Report bugs to %s.\n), program_name, DEFAULT_DIRECTORY / GRUB_ENVBLK_DEFCFG, PACKAGE_BUGREPORT); exit (status); @@ -287,7 +287,7 @@ main (int argc, char *argv[]) /* Obtain the filename. */ if (optind = argc) { - fprintf (stderr, no filename specified\n); + fprintf (stderr, _(no filename specified\n)); usage (1); } @@ -312,7 +312,7 @@ main (int argc, char *argv[]) unset_variables (filename, argc - optind - 2, argv + optind + 2); else { - fprintf (stderr, unknown command %s\n, command); + fprintf (stderr, _(unknown command %s\n), command); usage (1); } === modified file 'util/grub-emu.c' --- util/grub-emu.c 2010-02-07 16:30:16 + +++ util/grub-emu.c 2010-03-19 23:46:01 + @@ -126,10 +126,10 @@ usage (int status) { if (status) fprintf (stderr, - Try `%s --help' for more information.\n, program_name); + _(Try `%s --help' for more information.\n), program_name); else printf ( - Usage: %s [OPTION]...\n +_(Usage: %s [OPTION]...\n \n GRUB emulator.\n \n @@ -141,7 +141,7 @@ usage (int status) -h, --helpdisplay this message and exit\n -V, --version print version information and exit\n \n - Report bugs to %s.\n, program_name, DEFAULT_DEVICE_MAP, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT); + Report bugs to %s.\n), program_name, DEFAULT_DEVICE_MAP, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT); return status; } @@ -191,13 +191,13 @@ main (int argc, char *argv[]) if (optind argc) { - fprintf (stderr, Unknown extra argument `%s'.\n, argv[optind]); + fprintf (stderr, _(Unknown extra argument `%s'.\n), argv[optind]); return usage (1); } /* Wait until the ARGS.HOLD variable is cleared by an attached debugger. */ if (hold verbosity 0) -printf (Run \gdb %s %d\, and set ARGS.HOLD to zero.\n, +printf (_(Run \gdb %s %d\, and set ARGS.HOLD to zero.\n), program_name, (int) getpid ()); while (hold) { === modified file 'util/grub-fstest.c' --- util/grub-fstest.c 2010-01-27 01:49:11 + +++ util/grub-fstest.c 2010-03-19 23:46:01 + @@ -366,9 +366,9 @@ static void usage (int status) { if (status) -fprintf (stderr, Try `%s --help' for more information.\n, program_name); +fprintf (stderr, _(Try `%s --help' for more information.\n), program_name); else -printf (\ +printf (_(\ Usage: %s [OPTION
Re: Broken build
Hi, On Mar/17/2010, Bruce Dubbs wrote: With the addition of the internationalization code, building GRUB in a separate directory fails. I'll take a look into it soon (next days or next week) Probably it's an easy thing, if someone checks it before please report :-) Thanks for the report, -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] Add missing dependencies to INSTALL
Hi, On Mar/02/2010, Jordan Uggla wrote: Gettext and qemu ( for make-check ) are missing from INSTALL, AFAIK gettext is not a requirement, is it? If it's a requirement it could be just optional, but I would leave as a requirement since I understand that gettext is mainly everywhere. -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: Lead-up message 'Welcome to GRUB!' inverted text printed lowlevel via BIOS ?!?
Hi, On Feb/23/2010, edgar.sol...@web.de wrote: He never stated why he wanted it exactly. Maybe he just want's not to confuse an everyday user. or just for fun :-) -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
avoid possible overflow?
Hello, The common pattern when doing a search by bisection is something like: + current = min + (max - min) / 2; Instead of the first natural idea: - current = (max + min) / 2; To avoid overflows. In gettext/gettext.c it's used in the incorrect way. It's not a big problem since would happen only with .mo files with lot of strings, like number that int represents in that architecture divided by 2 (aprox aprox.). See the attached file for a patch if we want to patch. Else I would at least add a comment that we simplified because we consider that will not happen. Thanks, -- Carles Pina i Estany http://pinux.info === modified file 'ChangeLog' --- ChangeLog 2010-02-13 15:48:22 + +++ ChangeLog 2010-02-14 00:02:48 + @@ -1,3 +1,8 @@ +2010-02-13 Carles Pina i Estany car...@pina.cat + + * gettext/gettext.c (grub_gettext_translate): Avoids possible + overflow. + 2010-02-13 Vladimir Serbinenko phco...@gmail.com Merge grub_ieee1275_map_physical into grub_map and rename to === modified file 'gettext/gettext.c' --- gettext/gettext.c 2010-01-20 08:12:47 + +++ gettext/gettext.c 2010-02-13 23:56:58 + @@ -192,7 +192,7 @@ grub_gettext_translate (const char *orig grub_free (current_string); found = 1; } - current = (max + min) / 2; + current = min + (max - min) / 2; } ret = found ? grub_gettext_gettranslation_from_position (current) : orig; ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
keyboard layouts
Hi, There is pending to review the keyboard layout patch. Please don't do :-) on Friday I started a generalisation with USB. Currently I have the generalisation (not committed) and some problem with the USB that I need to investigate. During the weekend should be ready and I'll ping you again. Cheers, -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: Simplified Chinese screenshots
Hi, On Feb/01/2010, Chris Jones wrote: On Mon, Feb 01, 2010 at 04:32:14PM EST, Carles Pina i Estany wrote: Hi, Aron Xu sent me some screenshots of Grub booting time in Chinese: http://carles.lastdot.org/Screenshot-QEMU.png http://carles.lastdot.org/Screenshot-QEMU-1.png http://carles.lastdot.org/Screenshot-QEMU-2.png Thanks for posting this -- quite impressive. It would be nice to upload a few such multi-lingual screenshots to a grub-gallery section of the wiki, don't you think..? When more translations will be done I will consider/do it. If someone wants to do please go ahead :-) Nice to see that there are users who are able to do some useful stuff with the new grub, especially since lately, I have seen a couple of trolls spreading some pretty inane FUD about the new grub on the debian-user mailing list. I haven't read the insane FUD(s). One important thing that we are on it (Bruce I think) is writing documentation. Ok, we usually don't like it, but the time spent writting http://grub.enbug.org/TestGettext payedback very fast with the screenshots and I hope that more translators testing the translations... and people understanding a bit how it works or how to test it. (This is my only my opinion) -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: The next TestGettext step?
Hi, On Feb/01/2010, Jorma Karvonen wrote: I tried to test according to the following document: http://grub.enbug.org/TestGettext I installed everything and changed the path to grub-mkrescue a bit: Why have you changed the path of grub-mkrescue a bit? The instructions doesn't install Grub (not needed to test the translations), it only compiles Grub. I prefer it to mess up things in your machines. Also, you don't need sudo for the all process (beside installing packages) img$ sudo ./test.sh -no-kqemu Enabling BIOS support ... (null): error: cannot open .///moddep.lst. You do not have enough space in '/dev/shm' for the 128 MB of QEMU virtual RAM. To have more space available provided you have enough RAM and swap, do as root: umount /dev/shm mount -t tmpfs -o size=144m none /dev/shm Or disable the accelerator module with -no-kqemu I tried to umount /dev/shm but got the following message img$ sudo umount /dev/shm umount: /dev/shm: device is busy umount: /dev/shm: device is busy So I can't umount and mount again. What would be the next step? You don't need to umount it. could you try everything under Steps, not using sudo, not installing Grub? Which distribution do you use? Have you used qemu for something else? (that you would have some special qemu configuration). The iso file should be generated in your grub directory, not under img/ Cheers, -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: The next TestGettext step?
Hi, Do you mind if we move this thread to help-grub mailing list?: http://lists.gnu.org/mailman/listinfo/help-grub (I've updated the Wiki according to it too) Sorry for the subscribes-unsubscribes cycle. I send this mail CCed there, from now on I will reply in this thread only there. On Feb/01/2010, Jorma Karvonen wrote: I had already installed grub2 with ./configure -prefix=/usr/local and could not find grub-mkrescue in img directory. grub-mkrescue should not be in img/ directory, it should be in /usr/local/bin or in the same directory that you compiled Grub. Could you repeat the steps and same time copying-pasting what you type to an email? And try to use exactly the same steps that I described on the Wiki unless you have some reason to try something else. Or do the same steps and if you want to adjust something we do it after that. More people used that and worked fine, but of course, but it was with another Ubuntu or Debian. Thanks! -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Simplified Chinese screenshots
Hi, Aron Xu sent me some screenshots of Grub booting time in Chinese: http://carles.lastdot.org/Screenshot-QEMU.png http://carles.lastdot.org/Screenshot-QEMU-1.png http://carles.lastdot.org/Screenshot-QEMU-2.png I thought that was interesting to see Grub with other Unicode range than the more usual for me :-) (Yes, I know that Russian is there too) As Aron said: the font size is not constant, so we should fix it in some point. Cheers, -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
at_keyboard_layout
Hello, I've modified a bit the patch keyboard_layout.patch. Should apply to last trunk, plus it's called at_keyboard_layout. And the exported variable is in at_keyboard and not in kernel. Comments? Thanks, -- Carles Pina i Estany http://pinux.info === added file 'ChangeLog.at_keyboard_layouts' --- ChangeLog.at_keyboard_layouts 1970-01-01 00:00:00 + +++ ChangeLog.at_keyboard_layouts 2010-01-30 00:10:48 + @@ -0,0 +1,19 @@ +2010-01-18 Carles Pina i Estany car...@pina.cat + + Adds keyboard layouts support (only AT). + + * conf/common.rmk (bin_UTILITIES): Add grub-mklayouts rules. + (pkglib_MODULES): Add module `at_keyboard_layouts.mod'. + * include/grub/at_keyboard.h: New struct `grub_keyboard_map_s'. New + EXPORT_VAR `grub_keyboard_map'. + * include/grub/at_keyboard_layouts.h: New file. + * include/grub/keys.h: Move macros from here ... + * include/grub/term.h: ... to here. New file. + * at_keyboard_layouts/at_keyboard_layouts.c: New file. + * term/at_keyboard.c: Include `grub/mm.h'. + (keyboard_map_normal): Renamed from `keyboard_map'. + (grub_at_keyboard_getkey_noblock): Use `grub_keyboard_map' instead of + `keyboard_map' and `keyboard_map_shift'. + (grub_term_input): Initialise `grub_keyboard_map-normal' and + `grub_keyboard_map-shift'. + * util/grub-mklayouts.c: New file. === added directory 'at_keyboard_layouts' === added file 'at_keyboard_layouts/at_keyboard_layouts.c' --- at_keyboard_layouts/at_keyboard_layouts.c 1970-01-01 00:00:00 + +++ at_keyboard_layouts/at_keyboard_layouts.c 2010-01-29 23:56:38 + @@ -0,0 +1,194 @@ +/* at_keyboard_layouts.c - at_keyboard_layouts module */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2010 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see http://www.gnu.org/licenses/. + */ + +#include grub/types.h +#include grub/misc.h +#include grub/mm.h +#include grub/err.h +#include grub/dl.h +#include grub/normal.h +#include grub/file.h +#include grub/kernel.h +#include grub/i18n.h +#include grub/at_keyboard.h +#include grub/keyboard_layouts.h + +#include grub/term.h + +static char original_keyboard_layout_normal[128]; +static char original_keyboard_layout_shift[128]; + +static char *active_layout; + +static grub_err_t +grub_cmd_load_layout(grub_command_t cmd __attribute__ ((unused)), + int argc, char **args) +{ + char magic[8]; + int check; + char *filename; + char *prefix; + int filename_length; + + if (argc != 1) +return grub_error (GRUB_ERR_BAD_ARGUMENT, usage: load_layout LAYOUT); + + prefix = grub_env_get (keymaps_dir); + if (!prefix) +return grub_error (GRUB_ERR_READ_ERROR, + `keymaps_dir' variable not set up); + + filename_length = grub_strlen (prefix) + grub_strlen (/) + +grub_strlen (args[0]) + 1; + + filename = +grub_malloc (filename_length); + + if (! filename) +return grub_errno; + + grub_snprintf (filename, filename_length, %s/%s, prefix, args[0]); + + grub_file_t keyboard_file; + keyboard_file = grub_file_open (filename); + + if (!keyboard_file) +{ + return grub_error (GRUB_ERR_READ_ERROR, cannot open file `%s', + filename); + return 0; +} + + check = +grub_file_read (keyboard_file, magic, + sizeof (GRUB_KEYBOARD_LAYOUTS_FILEMAGIC) - 1); + + if (check != sizeof (GRUB_KEYBOARD_LAYOUTS_FILEMAGIC) - 1) +{ + return grub_error (GRUB_ERR_READ_ERROR, + cannot read the file header from `%s', filename); +} + + if (grub_memcmp + (magic, GRUB_KEYBOARD_LAYOUTS_FILEMAGIC, + sizeof (GRUB_KEYBOARD_LAYOUTS_FILEMAGIC) - 1) != 0) +{ + grub_file_close (keyboard_file); + return grub_error (GRUB_ERR_BAD_FILE_TYPE, file not recognised (`%s'), + filename); +} + grub_uint32_t version; + check = grub_file_read (keyboard_file, version, 4); + + if (check != 4) +{ + grub_file_close (keyboard_file); + return grub_error (GRUB_ERR_BAD_FILE_TYPE, + cannot check file version (`%s'), filename); +} + + version = grub_be_to_cpu32 (version); + if (version != GRUB_KEYBOARD_LAYOUTS_VERSION) +{ + grub_file_close (keyboard_file); + return grub_error (GRUB_ERR_BAD_FILE_TYPE, + invalid file version: %d (`%s'), version, + filename); +} + + + + check = grub_file_read (keyboard_file, grub_keyboard_map-normal, 128); + if (check != 128) +{ + grub_file_close
Re: Antialiased fonts patch.
Hi, On Jan/26/2010, Vladimir '??-coder/phcoder' Serbinenko wrote: Evgeny Kolesnikov wrote: So I can suggest to make division: 1-bit indexed text layer vs 8(32)-bit RGBA layer. First is for speed, second (and third) is for beauty Splitting speed/niceness is ok as long as they share most of the code and speed is default. how much slower would be? (just for curiosity). 10 ms per screen or 20 seconds? Perhaps we can have a variable: set i_want_to_waste_time_in_booter=yes I suggest set i_want_high_quality_fonts=yes (well, withought i_want). I would say that mainly everybody knows that high quality something usually has some payback. But before we can go to such length for beauty we would need native drivers first. No matter how you antialias if VBE accepts only 1024x768 which is stretched to 1280x800, it won't have any effect. Hence you need to port native drivers to grub. I understand and agree. -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: macrofy fontcontants
Hi, On Jan/26/2010, Vladimir '??-coder/phcoder' Serbinenko wrote: Evgeny Kolesnikov wrote: On Mon, 2010-01-25 at 23:07 +, Carles Pina i Estany wrote: Find attached a way to macrofy the constants from font files between util and grub kernel. Comments, name changes, etc. are welcomed. Can you please consider my patch for anti-aliased fonts in your scheme. It's in the way to be added into trunk. (http://lists.gnu.org/archive/html/grub-devel/2010-01/msg00301.html) There is no reason your pending patch should affect Carles' one. Well, someone has to adapt some code :-( It was on my pending list for some weeks... bad timing. But your one Evgeny is a bit bigger and may take some time Carles: Assuming, files generated by grub-mkfont are the same up to byte and you have tested rendering part, you can merge your patch I will double check and commit. Thanks, -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
gettext util/*
Hi, Here is the first patch to gettextizze strings in util/* (well, before some things has been done). Vladimir suggested to not gettext: + printf (_(\nGlyph #%d, U+%04x\n), num, glyph-char_code); + printf (_(Width %d, Height %d, X offset %d, Y offset %d, Device width %d\n), I'm fine to leave it out. It gettexts mainly everything but not grub_util_error / grub_util_info calls, waiting how we handle it (to be discussed later in another thread). Any feedback? Thanks, -- 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 util/*
On Jan/27/2010, Carles Pina i Estany wrote: Hi, Here is the first patch to gettextizze strings in util/* (well, before some things has been done). Now with the patch attached. -- Carles Pina i Estany http://pinux.info === modified file 'ChangeLog' --- ChangeLog 2010-01-26 21:23:59 + +++ ChangeLog 2010-01-26 22:26:23 + @@ -1,4 +1,20 @@ 2010-01-26 Carles Pina i Estany car...@pina.cat + + * util/grub-editenv.c: Gettextizze mainly all user interface strings + excepting grub_util_info or grub_util_error. + * util/grub-emu.c: Likewise. + * util/grub-fstest.c: Likewise. + * util/grub-macho2img.c: Likewise. + * util/grub-mkdevicemap.c: Likewise. + * util/grub-mkfont.c: Likewise. + * util/grub-mkpasswd-pbkdf2.c: Likewise. + * util/grub-mkrelpath.c: Likewise. + * util/grub-pe2elf.c: Likewise. + * util/grub-probe.c: Likewise. + * util/grub-script-check.c: Likewise. + * po/POTFILES: Add gettextizzed files. + +2010-01-26 Carles Pina i Estany car...@pina.cat * util/bin2h.c (usage): Fix warning (space after backslash). === modified file 'po/POTFILES' --- po/POTFILES 2010-01-21 08:04:49 + +++ po/POTFILES 2010-01-26 22:17:33 + @@ -77,5 +77,17 @@ normal/misc.c term/serial.c +util/grub-editenv.c +util/grub-emu.c +util/grub-fstest.c +util/grub-macho2img.c +util/grub-mkdevicemap.c +util/grub-mkfont.c +util/grub-mkpasswd-pbkdf2.c util/grub-mkrawimage.c +util/grub-mkrelpath.c +util/grub-pe2elf.c +util/grub-probe.c +util/grub-probe.c +util/grub-script-check.c util/i386/pc/grub-setup.c === modified file 'util/grub-editenv.c' --- util/grub-editenv.c 2010-01-16 00:39:14 + +++ util/grub-editenv.c 2010-01-26 22:05:13 + @@ -69,9 +69,9 @@ static void usage (int status) { if (status) -fprintf (stderr, Try `%s --help' for more information.\n, program_name); +fprintf (stderr, _(Try `%s --help' for more information.\n), program_name); else -printf (\ +printf (_(\ Usage: %s [OPTIONS] [FILENAME] COMMAND\n\ \n\ Tool to edit environment block.\n\ @@ -87,7 +87,7 @@ Tool to edit environment block.\n\ \n\ If not given explicitly, FILENAME defaults to %s.\n\ \n\ -Report bugs to %s.\n, +Report bugs to %s.\n), program_name, DEFAULT_DIRECTORY / GRUB_ENVBLK_DEFCFG, PACKAGE_BUGREPORT); exit (status); @@ -287,7 +287,7 @@ main (int argc, char *argv[]) /* Obtain the filename. */ if (optind = argc) { - fprintf (stderr, no filename specified\n); + fprintf (stderr, _(no filename specified\n)); usage (1); } @@ -312,7 +312,7 @@ main (int argc, char *argv[]) unset_variables (filename, argc - optind - 2, argv + optind + 2); else { - fprintf (stderr, unknown command %s\n, command); + fprintf (stderr, _(unknown command %s\n), command); usage (1); } === modified file 'util/grub-emu.c' --- util/grub-emu.c 2010-01-16 00:39:14 + +++ util/grub-emu.c 2010-01-26 22:06:02 + @@ -129,10 +129,10 @@ usage (int status) { if (status) fprintf (stderr, - Try `%s --help' for more information.\n, program_name); + _(Try `%s --help' for more information.\n), program_name); else printf ( - Usage: %s [OPTION]...\n +_(Usage: %s [OPTION]...\n \n GRUB emulator.\n \n @@ -144,7 +144,7 @@ usage (int status) -h, --helpdisplay this message and exit\n -V, --version print version information and exit\n \n - Report bugs to %s.\n, program_name, DEFAULT_DEVICE_MAP, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT); + Report bugs to %s.\n), program_name, DEFAULT_DEVICE_MAP, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT); return status; } @@ -191,13 +191,13 @@ main (int argc, char *argv[]) if (optind argc) { - fprintf (stderr, Unknown extra argument `%s'.\n, argv[optind]); + fprintf (stderr, _(Unknown extra argument `%s'.\n), argv[optind]); return usage (1); } /* Wait until the ARGS.HOLD variable is cleared by an attached debugger. */ if (hold verbosity 0) -printf (Run \gdb %s %d\, and set ARGS.HOLD to zero.\n, +printf (_(Run \gdb %s %d\, and set ARGS.HOLD to zero.\n), program_name, (int) getpid ()); while (hold) { === modified file 'util/grub-fstest.c' --- util/grub-fstest.c 2010-01-20 08:12:47 + +++ util/grub-fstest.c 2010-01-26 22:07:18 + @@ -367,9 +367,9 @@ static void usage (int status) { if (status) -fprintf (stderr, Try `%s --help' for more information.\n, program_name); +fprintf (stderr, _(Try `%s --help' for more information.\n), program_name); else -printf (\ +printf (_(\ Usage: %s [OPTION]... IMAGE_PATH COMMANDS\n\ \n\ Debug tool for filesystem driver.\n\ @@ -390,7 +390,7 @@ Debug tool for filesystem driver.\n\ -V, --version print version information and exit\n\ -v, --verbose print verbose messages\n\ \n\ -Report bugs to %s.\n, program_name, PACKAGE_BUGREPORT); +Report
Re: comment about grub_error, capitalisation and one commit
Hi, On Jan/24/2010, Robert Millan wrote: On Wed, Jan 20, 2010 at 11:37:38PM +, Carles Pina i Estany wrote: a) if someone has a better idea to avoid this mistake again than paying attention I can implement. b) Robert: I reverse it, fine? I just removed capitalization of error strings in the whole file. A generic check would be nice. If you'd like to implement it, I think it should be possible to verify this entirely in build time. I'll think about it soon. Build time can be a bit difficult: if the sentence starts with Linux / Unix / MS-DOS / ... then needs to be capitalized (we can have a blacklist of words) -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
macrofy fontcontants
Hello, Find attached a way to macrofy the constants from font files between util and grub kernel. Comments, name changes, etc. are welcomed. -- Carles Pina i Estany http://pinux.info === modified file 'ChangeLog' --- ChangeLog 2010-01-25 17:04:22 + +++ ChangeLog 2010-01-25 23:03:56 + @@ -1,3 +1,12 @@ +2010-01-25 Carles Pina i Estany car...@pina.cat + + * font/font.c: Include `grub/fontformat.h. + Remove font file format constants. + (grub_font_load): Use the new constant names. + * include/grub/fontformat.h: New file. + * util/grub-mkfont.c: Include `grub/fontformat.c'. + (write_font_pf2): Use the new macros instead of hardcoded literals. + 2010-01-25 Colin Watson cjwat...@ubuntu.com * util/hostdisk.c (open_device): Add trailing newline to debug === modified file 'font/font.c' --- font/font.c 2010-01-20 20:53:43 + +++ font/font.c 2010-01-25 23:04:38 + @@ -26,6 +26,7 @@ #include grub/types.h #include grub/video.h #include grub/bitmap.h +#include grub/fontformat.h #ifdef USE_ASCII_FAILBACK #include ascii.h @@ -89,19 +90,6 @@ struct font_file_section int eof; }; -/* Font file format constants. */ -static const char pff2_magic[4] = { 'P', 'F', 'F', '2' }; -static const char section_names_file[4] = { 'F', 'I', 'L', 'E' }; -static const char section_names_font_name[4] = { 'N', 'A', 'M', 'E' }; -static const char section_names_point_size[4] = { 'P', 'T', 'S', 'Z' }; -static const char section_names_weight[4] = { 'W', 'E', 'I', 'G' }; -static const char section_names_max_char_width[4] = { 'M', 'A', 'X', 'W' }; -static const char section_names_max_char_height[4] = { 'M', 'A', 'X', 'H' }; -static const char section_names_ascent[4] = { 'A', 'S', 'C', 'E' }; -static const char section_names_descent[4] = { 'D', 'E', 'S', 'C' }; -static const char section_names_char_index[4] = { 'C', 'H', 'I', 'X' }; -static const char section_names_data[4] = { 'D', 'A', 'T', 'A' }; - /* Replace unknown glyphs with a rounded question mark. */ static grub_uint8_t unknown_glyph_bitmap[] = { @@ -460,7 +448,8 @@ grub_font_load (const char *filename) #if FONT_DEBUG = 3 grub_printf(opened FILE section\n); #endif - if (grub_memcmp (section.name, section_names_file, 4) != 0) + if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_FILE, + sizeof(FONT_FORMAT_SECTION_NAMES_FILE) - 1) != 0) { grub_error (GRUB_ERR_BAD_FONT, font file format error: 1st section must be FILE); @@ -489,7 +478,7 @@ grub_font_load (const char *filename) grub_printf(read magic ok\n); #endif - if (grub_memcmp (magic, pff2_magic, 4) != 0) + if (grub_memcmp (magic, FONT_FORMAT_PFF2_MAGIC, 4) != 0) { grub_error (GRUB_ERR_BAD_FONT, invalid font magic %x %x %x %x, magic[0], magic[1], magic[2], magic[3]); @@ -529,18 +518,22 @@ grub_font_load (const char *filename) section.name[2], section.name[3]); #endif - if (grub_memcmp (section.name, section_names_font_name, 4) == 0) + if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_FONT_NAME, + sizeof(FONT_FORMAT_SECTION_NAMES_FONT_NAME) - 1) == 0) { font-name = read_section_as_string (section); if (!font-name) goto fail; } - else if (grub_memcmp (section.name, section_names_point_size, 4) == 0) + else if (grub_memcmp (section.name, + FONT_FORMAT_SECTION_NAMES_POINT_SIZE, + sizeof(FONT_FORMAT_SECTION_NAMES_POINT_SIZE) - 1) == 0) { if (read_section_as_short (section, font-point_size) != 0) goto fail; } - else if (grub_memcmp (section.name, section_names_weight, 4) == 0) + else if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_WEIGHT, + sizeof(FONT_FORMAT_SECTION_NAMES_WEIGHT) - 1) == 0) { char *wt; wt = read_section_as_string (section); @@ -553,32 +546,42 @@ grub_font_load (const char *filename) font-weight = FONT_WEIGHT_BOLD; grub_free (wt); } - else if (grub_memcmp (section.name, section_names_max_char_width, 4) == 0) + else if (grub_memcmp (section.name, + FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH, + sizeof(FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH) - 1) == 0) { if (read_section_as_short (section, font-max_char_width) != 0) goto fail; } - else if (grub_memcmp (section.name, section_names_max_char_height, 4) == 0) + else if (grub_memcmp (section.name, + FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT, + sizeof(FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT) - 1) == 0) { if (read_section_as_short (section, font-max_char_height) != 0) goto fail; } - else if (grub_memcmp (section.name, section_names_ascent, 4) == 0) + else if (grub_memcmp (section.name
handling /
Hi, I've seen a couple of patches about handling /. In Linux (I think that it's up to Linux, but maybe is libc?) things like ///bin/ are valid. Or things like /var/tmp// Is this not everywhere? I've not verified if POSIX paths says this, but would avoid the things that has been patching and unpatching today. Just asking/commenting to know. -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
comment about grub_error, capitalisation and one commit
Hi, grub_error strings are printed by kern/err.c and are printed after : like: Error: %s (talking from memory) One commit from Robert did: if (argc == 0) -return grub_error (GRUB_ERR_BAD_ARGUMENT, no initrd specified); +return grub_error (GRUB_ERR_BAD_ARGUMENT, No initrd specified); if (!loaded) -return grub_error (GRUB_ERR_BAD_ARGUMENT, You need to load the kernel first.); +return grub_error (GRUB_ERR_BAD_ARGUMENT, You need to load Linux first.); This should not be capitalised. r...@aybabtu.com-20100120012906-xlsv7y7f9go2e3ig Wed 2010-01-20 01:29:06 + * loader/mips/linux.c (grub_cmd_initrd) (GRUB_MOD_INIT(linux)): Adjust and gettextize a few strings. So: a) if someone has a better idea to avoid this mistake again than paying attention I can implement. b) Robert: I reverse it, fine? Cheers, -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: keyboard layout patches
Hi, On Jan/20/2010, Robert Millan wrote: On Mon, Jan 18, 2010 at 07:25:37PM +, Carles Pina i Estany wrote: Also keyboard_layouts is pretty small. Perhaps we can just make *_keyboard depend on it and put US keyboard into it as default and shave some complexity this way How it would work in rescue mode and at_keyboard? I mean, extreme cases that Grub for some reason could not reach the keyboard layout file. What's the total size we're talking about? Layout files are 268 bytes (128 for standard layout, 128 for shift and some headers, 8 bytes for filemagic, 4 bytes for version) keyboard_layouts.mod is 3164. Aprox 520 with error messages, maybe now is too much detailed. -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: keyboard layout patches
Hi, I answer in fast way... more at evening. Items that I don't comment I understand and agree. On Jan/18/2010, Vladimir '??-coder/phcoder' Serbinenko wrote: How could grub-mkinstall (00_header.in) know the current keyboard in the system? setxkbmap -print will give you the x layout but it won't work outside of X. I wold tweak 00_header.in to generate the keymap file and setup it. It may be executed by a daemon with no X available. I'll use Felix suggestion: do whatever is in /etc/grub/default + filename = +grub_malloc (grub_strlen (prefix) + grub_strlen (/) + + grub_strlen (args[0]) + 1); Can you add support for complete filenames? do you mean that, for example, if args[0] starts by / then filename = args[0]? Actually if prefix (that it's a variable) is / then args[0] acts as a filename. Would be like ///test/filename and it's a valid directory. Can you think of a way to restoring keyboard map to English? unloading the module restores the original keyboard (so, English one). I save the original one when the module is loaded. Thanks for the other comments, -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: keyboard layout patches
Hi, On Jan/18/2010, Vladimir '??-coder/phcoder' Serbinenko wrote: Carles Pina i Estany wrote: Actually if prefix (that it's a variable) is / then args[0] acts as a filename. Would be like ///test/filename and it's a valid directory. Perhaps we should remove prefix variables altogether. I understand that you mean that the user would type: load_keyboard /boot/grub/layouts/es right? (in the shell or the config file) Comments on this? (I don't like it, I would even prefer to have the prefix hardcoded or like it's now) Can you think of a way to restoring keyboard map to English? unloading the module restores the original keyboard (so, English one). I save the original one when the module is loaded. I mean imagine that you're in a face to a grub with klingon keyboard how would you find your way out? Klingon is my primary layout! :-) I have different things to say and we could discuss quite long, but let's jump to the ideas: a) very short term: what about to register a command to something (like 1234, numbers doesn't usually change between keyboard, right? or ** for the keypad -I should check that it works, but would fix if it doesn't) that reverts to English? b) medium term: as you suggested some days ago on IRC: Shift+Shift, or Ctrl+Shift or something like this reverts to English. I'm not sure about the infrastructure needed for b) Also keyboard_layouts is pretty small. Perhaps we can just make *_keyboard depend on it and put US keyboard into it as default and shave some complexity this way How it would work in rescue mode and at_keyboard? I mean, extreme cases that Grub for some reason could not reach the keyboard layout file. The complexitity that we save is very reduced. -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: keyboard layout patches
Hi, On Jan/18/2010, Vladimir '??-coder/phcoder' Serbinenko wrote: + grub_util_write_image (GRUBLAY, 7, fp); + grub_util_write_image ((char *) version, 4, fp); should be macroified and put somewhere in a header instead of duplicating I agree. Any reason that I don't see that in util/grub-mkfont.c: grub_util_write_image (FILE, 4, file); grub_util_write_image (PFF2, 4, file); and then in font/font.c: static const char section_names_file[4] = { 'F', 'I', 'L', 'E' }; static const char pff2_magic[4] = { 'P', 'F', 'F', '2' }; ? If should be in a macro (as I think so) I will fix after finishing other things. Cheers, -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: keyboard layout patches
Hi, On Jan/18/2010, Colin Watson wrote: On Mon, Jan 18, 2010 at 07:25:37PM +, Carles Pina i Estany wrote: a) very short term: what about to register a command to something (like 1234, numbers doesn't usually change between keyboard, right? The standard counterexample is French. Function keys do stay constant, though. Usually are not mapped to any ASCII output to call a command. I know that I can do it idfferent, but then it's not option a). What about the star in the numeric pad? Is it constant for all keyboards? (I can check generating all keymaps and a script, but maybe you know on the top of your head) -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: keyboard layout patches
Hi, On Jan/18/2010, Carles Pina i Estany wrote: I've done a first version of keyboard_layout. Find a patch attached, or Thanks to the comments from different people in the thread, I send a new version. It does, on from my head: a) Constants used in util/ and Grub are in a common header file. b) Use 8 bytes magic file, instead of 7 c) Adds a new command ** to revert to the default keyboard d) Don't use popen and use fork + execlp + pipe e) Change some names that I didn't like f) Implements a new variable in /etc/grub/default And some other small bugfixes. Everything is tested but not f). The solution of c) is temporary, but I think that good enough for this stage. When this is in trunk/experimental (I think that can go to trunk straight away since there isn't major changes, but I give it up to you) I can implement some other solution. What else I should change, or some other comment? Thanks, -- Carles Pina i Estany http://pinux.info === added file 'ChangeLog.keyboard_layouts' --- ChangeLog.keyboard_layouts 1970-01-01 00:00:00 + +++ ChangeLog.keyboard_layouts 2010-01-18 21:27:43 + @@ -0,0 +1,22 @@ +2010-01-18 Carles Pina i Estany car...@pina.cat + + Adds keyboard layouts support. + + * conf/common.rmk (bin_UTILITIES): Add grub-mklayouts rules. + (pkglib_MODULES): Add module `keyboard_layouts.mod'. + * include/grub/keyboard_layouts.h: New file. + * include/grub/term.h: New struct `grub_keyboard_map_s'. New + EXPORTED_VAR `grub_keyboard_map'. Move GRUB_TERM_* keys definitions + to... + * include/grub/keys.h: ... here. New file. + * kern/term.c (grub_keyboard_map): Initialise to NULL. + * keyboard_layouts/keyboard_layouts.c: New file. + * term/i386/pc/at_keyboard.c: Include `grub/mm.h'. + (keyboard_map_normal): Renamed from `keyboard_map'. + (grub_at_keyboard_getkey_noblock): Use `grub_keyboard_map' instead of + `keyboard_map' and `keyboard_map_shift'. + (grub_term_input): Initialise `grub_keyboard_map-normal' and + `grub_keyboard_map-shift'. + * util/grub-mklayouts.c: New file. + * util/grub-mkconfig.in: New variable `GRUB_KEYBOARD_LAYOUT'. + * util/grub.d/00_header.in: Set up layout configuration. === modified file 'conf/common.rmk' --- conf/common.rmk 2010-01-14 14:04:44 + +++ conf/common.rmk 2010-01-17 14:35:00 + @@ -88,6 +88,10 @@ endif bin_UTILITIES += grub-mkrelpath grub_mkrelpath_SOURCES = gnulib/progname.c util/grub-mkrelpath.c util/misc.c +# For grub-mklayouts. +bin_UTILITIES += grub-mklayouts +grub_mklayouts_SOURCES = gnulib/progname.c util/grub-mklayouts.c util/misc.c + # For the parser. grub_script.tab.c grub_script.tab.h: script/parser.y $(YACC) -d -p grub_script_yy -b grub_script $(srcdir)/script/parser.y @@ -647,6 +651,12 @@ gettext_mod_SOURCES = gettext/gettext.c gettext_mod_CFLAGS = $(COMMON_CFLAGS) gettext_mod_LDFLAGS = $(COMMON_LDFLAGS) +# For keyboard_layouts.mod +pkglib_MODULES += keyboard_layouts.mod +keyboard_layouts_mod_SOURCES = keyboard_layouts/keyboard_layouts.c +keyboard_layouts_mod_CFLAGS = $(COMMON_CFLAGS) +keyboard_layouts_mod_LDFLAGS = $(COMMON_LDFLAGS) + # Misc. pkglib_MODULES += xnu_uuid.mod === added file 'include/grub/keyboard_layouts.h' --- include/grub/keyboard_layouts.h 1970-01-01 00:00:00 + +++ include/grub/keyboard_layouts.h 2010-01-18 22:13:06 + @@ -0,0 +1,25 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2010 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see http://www.gnu.org/licenses/. + */ + +#ifndef GRUB_KEYBOARD_LAYOUTS_H +#define GRUB_KEYBOARD_LAYOUTS_H 1 + +#define GRUB_KEYBOARD_LAYOUTS_FILEMAGIC GRUBLAYO +#define GRUB_KEYBOARD_LAYOUTS_VERSION 1 + +#endif /* GRUB_USB_H */ === added file 'include/grub/keys.h' --- include/grub/keys.h 1970-01-01 00:00:00 + +++ include/grub/keys.h 2010-01-17 18:21:42 + @@ -0,0 +1,36 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2010 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General
keyboard layout patches
Hello, I've done a first version of keyboard_layout. Find a patch attached, or check the branch: bzr.savannah.gnu.org/srv/bzr/grub/people/cpina/keyboard_layouts I've tested only in at_keyboard. Using something like: insmod at_keyboard terminal_input at_keyboard insmod keyboard_layouts set keymaps_dir=/boot/grub/layouts load_keyboard es and before I generate the file called es and copied into /boot/grub/layouts using grub-mklayout es How could grub-mkinstall (00_header.in) know the current keyboard in the system? I wold tweak 00_header.in to generate the keymap file and setup it. Comments about the current patch are welcomed, I would change it on next days. Some days ago I read: There are 2 hard problems in computer science: cache invalidation, naming things, and off-by-1 errors. Don't hesitate to tell me how would you rename some things, I'll do. I'm not happy with the name of some variables/functions but I cannot think about it today :-) Cheers, -- Carles Pina i Estany http://pinux.info === modified file 'conf/common.rmk' --- conf/common.rmk 2010-01-14 14:04:44 + +++ conf/common.rmk 2010-01-17 14:35:00 + @@ -88,6 +88,10 @@ endif bin_UTILITIES += grub-mkrelpath grub_mkrelpath_SOURCES = gnulib/progname.c util/grub-mkrelpath.c util/misc.c +# For grub-mklayouts. +bin_UTILITIES += grub-mklayouts +grub_mklayouts_SOURCES = gnulib/progname.c util/grub-mklayouts.c util/misc.c + # For the parser. grub_script.tab.c grub_script.tab.h: script/parser.y $(YACC) -d -p grub_script_yy -b grub_script $(srcdir)/script/parser.y @@ -647,6 +651,12 @@ gettext_mod_SOURCES = gettext/gettext.c gettext_mod_CFLAGS = $(COMMON_CFLAGS) gettext_mod_LDFLAGS = $(COMMON_LDFLAGS) +# For keyboard_layouts.mod +pkglib_MODULES += keyboard_layouts.mod +keyboard_layouts_mod_SOURCES = keyboard_layouts/keyboard_layouts.c +keyboard_layouts_mod_CFLAGS = $(COMMON_CFLAGS) +keyboard_layouts_mod_LDFLAGS = $(COMMON_LDFLAGS) + # Misc. pkglib_MODULES += xnu_uuid.mod === added file 'include/grub/keys.h' --- include/grub/keys.h 1970-01-01 00:00:00 + +++ include/grub/keys.h 2010-01-17 18:21:42 + @@ -0,0 +1,36 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2010 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see http://www.gnu.org/licenses/. + */ + +#ifndef GRUB_KEYS_HEADER +#define GRUB_KEYS_HEADER 1 + +/* Internal codes used by GRUB to represent terminal input. */ +#define GRUB_TERM_LEFT 2 +#define GRUB_TERM_RIGHT 6 +#define GRUB_TERM_UP16 +#define GRUB_TERM_DOWN 14 +#define GRUB_TERM_HOME 1 +#define GRUB_TERM_END 5 +#define GRUB_TERM_DC4 +#define GRUB_TERM_PPAGE 7 +#define GRUB_TERM_NPAGE 3 +#define GRUB_TERM_ESC '\e' +#define GRUB_TERM_TAB '\t' +#define GRUB_TERM_BACKSPACE 8 + +#endif /* ! GRUB_KEYS_HEADER */ === modified file 'include/grub/term.h' --- include/grub/term.h 2010-01-09 22:42:17 + +++ include/grub/term.h 2010-01-17 22:25:58 + @@ -19,19 +19,7 @@ #ifndef GRUB_TERM_HEADER #define GRUB_TERM_HEADER 1 -/* Internal codes used by GRUB to represent terminal input. */ -#define GRUB_TERM_LEFT 2 -#define GRUB_TERM_RIGHT 6 -#define GRUB_TERM_UP 16 -#define GRUB_TERM_DOWN 14 -#define GRUB_TERM_HOME 1 -#define GRUB_TERM_END 5 -#define GRUB_TERM_DC 4 -#define GRUB_TERM_PPAGE 7 -#define GRUB_TERM_NPAGE 3 -#define GRUB_TERM_ESC '\e' -#define GRUB_TERM_TAB '\t' -#define GRUB_TERM_BACKSPACE 8 +#include grub/keys.h #ifndef ASM_FILE @@ -198,6 +186,14 @@ extern struct grub_term_input *EXPORT_VA extern struct grub_term_output *EXPORT_VAR(grub_term_outputs); extern struct grub_term_input *EXPORT_VAR(grub_term_inputs); +struct grub_keyboard_map_s +{ + char *normal; + char *shift; +}; + +extern struct grub_keyboard_map_s *EXPORT_VAR(grub_keyboard_map); + static inline void grub_term_register_input (const char *name __attribute__ ((unused)), grub_term_input_t term) === modified file 'kern/term.c' --- kern/term.c 2009-12-27 21:35:40 + +++ kern/term.c 2010-01-17 21:52:16 + @@ -30,6 +30,8 @@ struct grub_term_input *grub_term_inputs void (*grub_newline_hook) (void) = NULL; +struct grub_keyboard_map_s *grub_keyboard_map = NULL; + /* Put a Unicode character. */ void grub_putcode (grub_uint32_t code, struct grub_term_output *term) === added directory
keyboard_layouts proof of concept
Hi, I've done a test, mainly to get more feedback from you. Find it attached. What it does: a) It defines a new Kernel symbol to be used from at_keyboard.c and from the new module keyboard_layouts. b) When the new module wants it changes the active keyboard_layouts. Big question: * How to deal with USB keyboards? One option would be to add a middle layer who receive some Grub key code and layouts are based on this level. I have not looked into it yet (doing some tests I renamed somethiing in the USB module, this is just a test to avoid some clashes before) If the proof of concept approach is the correct one I would define and export a structure who would have the keymap and keymap_shift, instead of having to export one variable per thing. Plus will be more scalable for dead keys. When this looks fine, my idea is to use the output of ckbcomp to prepare the files that will be in /boot/grub/layouts and that Grub (the new module) will read easily. Something like grub-mklayouts. I will think and implement other fancy things that we would need, like changing between keyboards easily. I just want to go step by step and maybe have something for trunk soon. Now (only for some time) and tomorrow I'll be on the IRC, so feel free to comment here (better for archiving) or there (better for questions and answers). Thanks, -- Carles Pina i Estany http://pinux.info === modified file 'conf/common.rmk' --- conf/common.rmk 2010-01-14 14:04:44 + +++ conf/common.rmk 2010-01-17 01:12:20 + @@ -647,6 +647,12 @@ gettext_mod_SOURCES = gettext/gettext.c gettext_mod_CFLAGS = $(COMMON_CFLAGS) gettext_mod_LDFLAGS = $(COMMON_LDFLAGS) +# For keyboard_layouts.mod +pkglib_MODULES += keyboard_layouts.mod +keyboard_layouts_mod_SOURCES = keyboard_layouts/keyboard_layouts.c +keyboard_layouts_mod_CFLAGS = $(COMMON_CFLAGS) +keyboard_layouts_mod_LDFLAGS = $(COMMON_LDFLAGS) + # Misc. pkglib_MODULES += xnu_uuid.mod === modified file 'include/grub/term.h' --- include/grub/term.h 2010-01-09 22:42:17 + +++ include/grub/term.h 2010-01-17 01:16:32 + @@ -197,6 +197,7 @@ extern struct grub_term_output *EXPORT_V extern struct grub_term_input *EXPORT_VAR(grub_term_inputs_disabled); extern struct grub_term_output *EXPORT_VAR(grub_term_outputs); extern struct grub_term_input *EXPORT_VAR(grub_term_inputs); +extern char *EXPORT_VAR(grub_keyboard_map); static inline void grub_term_register_input (const char *name __attribute__ ((unused)), === modified file 'kern/term.c' --- kern/term.c 2009-12-27 21:35:40 + +++ kern/term.c 2010-01-17 01:17:34 + @@ -30,6 +30,8 @@ struct grub_term_input *grub_term_inputs void (*grub_newline_hook) (void) = NULL; +char* grub_keyboard_map = NULL; + /* Put a Unicode character. */ void grub_putcode (grub_uint32_t code, struct grub_term_output *term) === added directory 'keyboard_layouts' === added file 'keyboard_layouts/keyboard_layouts.c' --- keyboard_layouts/keyboard_layouts.c 1970-01-01 00:00:00 + +++ keyboard_layouts/keyboard_layouts.c 2010-01-17 01:12:31 + @@ -0,0 +1,36 @@ +#include grub/types.h +#include grub/misc.h +#include grub/mm.h +#include grub/err.h +#include grub/dl.h +#include grub/normal.h +#include grub/file.h +#include grub/kernel.h +#include grub/i18n.h + +#include grub/term.h + +static grub_err_t +grub_cmd_load_keyboardlayout (grub_command_t cmd __attribute__ ((unused)), + int argc, char **args) +{ + if (argc != 1) +return grub_error (GRUB_ERR_BAD_ARGUMENT, usage: load_keyboard layout); + + grub_printf (Load layout %s, args[0]); + + grub_keyboard_map [2] = 'X'; /* '1' is 'X'. */ + return 0; +} + +GRUB_MOD_INIT (keyboard_layouts) +{ + grub_register_command_p1 (load_keyboard, grub_cmd_load_keyboardlayout, + N_(layout), + N_(Set ups the new layout.)); +} + +GRUB_MOD_FINI (keyboard_layouts) +{ + /* TODO: Restore the default layout. */ +} === modified file 'term/i386/pc/at_keyboard.c' --- term/i386/pc/at_keyboard.c 2010-01-09 22:42:17 + +++ term/i386/pc/at_keyboard.c 2010-01-17 00:59:51 + @@ -22,6 +22,7 @@ #include grub/i386/io.h #include grub/misc.h #include grub/term.h +#include grub/mm.h static short at_keyboard_status = 0; @@ -40,7 +41,7 @@ static grub_uint8_t led_status; #define KEYBOARD_LED_NUM (1 1) #define KEYBOARD_LED_CAPS (1 2) -static char keyboard_map[128] = +static char keyboard_map_default[128] = { '\0', GRUB_TERM_ESC, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', GRUB_TERM_BACKSPACE, GRUB_TERM_TAB, @@ -213,12 +214,12 @@ grub_at_keyboard_getkey_noblock (void) break; default: if (at_keyboard_status (KEYBOARD_STATUS_CTRL_L | KEYBOARD_STATUS_CTRL_R)) - key = keyboard_map[code] - 'a' + 1; + key = grub_keyboard_map[code] - 'a' + 1; else if ((at_keyboard_status (KEYBOARD_STATUS_SHIFT_L | KEYBOARD_STATUS_SHIFT_R)) keyboard_map_shift[code]) key = keyboard_map_shift[code]; else - key = keyboard_map[code]; + key
Re: keyboard layouts
Hi, On Jan/12/2010, Colin Watson wrote: On Tue, Jan 12, 2010 at 09:47:43PM +, Carles Pina i Estany wrote: Plan: * Approach 2 Small program (I guess that you prefer C, Python would be nice too) that when Grub is installed would process the /usr/share/X11/xkb/symbols files and generates the files that Grub will read. Code to read this files would be much easier than before. This way, the layout tables could stay in /boot/grub/layouts . These files would look like keycode - symbol pairs. Everything already in binary, and only for the things that differ from English. So, if a layout has 40 different keycode-symbol pairs compared with English, this would be 80 bytes per layout. Probably will be more, but it should be of this order of magnitude. I can't remember whether I mentioned this before, but have a look at I haven't read about it previously. the gfxboot-theme-ubuntu package in Ubuntu, specifically the scrape-console-setup script. It makes use of console-setup to process XKB keymaps into a form that can then be run through loadkeys and reformatted so that gfxboot can use them. A similar approach might be feasible in GRUB. Legal question: gfxboot-theme-ubuntu is licensed under GPL 2. I understand that this means that we cannot share code. In the other hand, I think that you are the author, so you could give the copyright of this code to the FSF if needed. Is it possible? Integration question: some of that code is done using Perl. Actually are quite small scripts (373 lines the longer one). I don't know if we want to add Perl as a Grub dependency :-/, or if it's worth. We can redo the script in C. Ok, the process of scrape-console-setup (I have not been able to test it yet) is to use ckbcomp to convert from XKB keymaps to the loadkeys keymaps, and then does some process on this second keymaps. My approach was avoiding ckbcomp (actually I didn't know it :-) ). The loadkeys keymaps are easier to parse, so for me looks fine to use. In the other hand adds a new dependency, only for the laziness of processing the XKB layouts. Can you write in two lines the format of the layout that gfxboot use? (else I will try to generate it soon...) Thanks, -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
error message
Hello, Last part to add gettext support is loader/*. Specially some grub_error messages, since some of them appears to the standard user. I thought to translate the common ones only, but it's a bit difficult to know the common ones. Then the appraoch is to add gettext support to all grub_error messages in loader/* (see the attached patch for reference). The strings are not very uniform. One option would be to try to make the strings from grub_error a bit more standard. One suggestion would be: * use an enum with all strings inside. So when we write a grub_error we will pick up one of them. We could have grub_error and grub_error_enum (so we don't loose the capacity to write other strings but we discourage). * also print the filename, line number from where the error has happened. So when a user comes and says Grub says no filename specified we would have some more information. (any problem to use the gcc macros to know the filename/line number? I remember something and I cannot find it now) Any other ideas? The goals are two, and a bit contradictory at first glance: a) Have less strings b) Have more precise error messages -- Carles Pina i Estany http://pinux.info === modified file 'ChangeLog' --- ChangeLog 2010-01-06 22:00:57 + +++ ChangeLog 2010-01-06 22:32:35 + @@ -1,5 +1,24 @@ 2010-01-06 Carles Pina i Estany car...@pina.cat + * kern/err.c (grub_print_error): Gettextizze error message. + * commands/boot.c: Gettextizze grub_error calls, grub_register_command + calls, include `grub/i18n.h' if needed. + * loader/i386/bsd.c: Likewise. + * loader/i386/efi/linux.c: Likewise. + * loader/i386/ieee1275/linux.c: Likewise. + * loader/i386/linux.c: Likewise. + * loader/i386/multiboot.c: Likewise. + * loader/i386/pc/linux.c: Likewise. + * loader/multiboot2.c: Likewise. + * loader/powerpc/ieee1275/linux.c: Likewise. + * loader/sparc64/ieee1275/linux.c: Likewise. + * po/POTFILES: Add `kern/err.c', `loader/i386/efi/linux.c', + `loader/i386/ieee1275/linux.c', `loader/i386/linux.c', + `loader/i386/multiboot.c', `loader/i386/pc/linux.c', + `loader/multiboot2.c' and `loader/powerpc/ieee1275/linux.c' files. + +2010-01-06 Carles Pina i Estany car...@pina.cat + * kern/err.c: Include `grub/i18n.h'. (grub_print_error): Add full stop. Gettextizze. * loader/i386/bsd.c (grub_netbsd_boot): Change grub_error description. === modified file 'commands/boot.c' --- commands/boot.c 2010-01-03 18:24:22 + +++ commands/boot.c 2010-01-06 22:07:04 + @@ -144,7 +144,7 @@ grub_loader_boot (void) struct grub_preboot_t *cur; if (! grub_loader_loaded) -return grub_error (GRUB_ERR_NO_KERNEL, no loaded kernel); +return grub_error (GRUB_ERR_NO_KERNEL, N_(no loaded kernel)); if (grub_loader_noreturn) grub_machine_fini (); === modified file 'kern/err.c' --- kern/err.c 2010-01-06 22:00:57 + +++ kern/err.c 2010-01-06 22:07:27 + @@ -122,7 +122,7 @@ grub_print_error (void) do { if (grub_errno != GRUB_ERR_NONE) -grub_err_printf (_(error: %s.\n), grub_errmsg); +grub_err_printf (_(error: %s.\n), _(grub_errmsg)); } while (grub_error_pop ()); === modified file 'loader/i386/bsd.c' --- loader/i386/bsd.c 2010-01-06 22:00:57 + +++ loader/i386/bsd.c 2010-01-06 22:42:49 + @@ -680,7 +680,7 @@ grub_netbsd_boot (void) + sizeof (struct grub_netbsd_btinfo_mmap_header) + count * sizeof (struct grub_netbsd_btinfo_mmap_entry) grub_os_area_addr + grub_os_area_size) -return grub_error (GRUB_ERR_OUT_OF_MEMORY, out of memory); +return grub_error (GRUB_ERR_OUT_OF_MEMORY, N_(out of memory)); curarg = mmap = (struct grub_netbsd_btinfo_mmap_header *) kern_end; pm = (struct grub_netbsd_btinfo_mmap_entry *) (mmap + 1); @@ -751,10 +751,10 @@ grub_bsd_load_aout (grub_file_t file) return grub_errno; if (grub_file_read (file, ah, sizeof (ah)) != sizeof (ah)) -return grub_error (GRUB_ERR_READ_ERROR, cannot read the a.out header); +return grub_error (GRUB_ERR_READ_ERROR, N_(cannot read the a.out header)); if (grub_aout_get_type (ah) != AOUT_TYPE_AOUT32) -return grub_error (GRUB_ERR_BAD_OS, invalid a.out header); +return grub_error (GRUB_ERR_BAD_OS, N_(invalid a.out header)); entry = ah.aout32.a_entry 0xFF; @@ -772,7 +772,7 @@ grub_bsd_load_aout (grub_file_t file) } if (load_addr 0x10) -return grub_error (GRUB_ERR_BAD_OS, load address below 1M); +return grub_error (GRUB_ERR_BAD_OS, N_(load address below 1M)); kern_start = load_addr; kern_end = load_addr + ah.aout32.a_text + ah.aout32.a_data; @@ -812,7 +812,7 @@ grub_bsd_elf32_hook (Elf32_Phdr * phdr, if ((paddr grub_os_area_addr) || (paddr + phdr-p_memsz grub_os_area_addr + grub_os_area_size)) -return grub_error (GRUB_ERR_OUT_OF_RANGE, address 0x%x is out of range, +return grub_error (GRUB_ERR_OUT_OF_RANGE, N_(address 0x%x is out of range), paddr); if ((!kern_start
Re: [PATCH] spaces (label, UUID)
Hi, On Jan/01/2010, Isaac Dupree wrote: Carles Pina i Estany wrote: +grub_putchar (' '); +grub_printf_ (N_(- Label \%s\), label); ... Avoiding to have trailing spaces helps the translators (they will do less mistakes). In this case it is a space at the beginning, not the end of the string -- does it still have this problem for translators? Or are I would say that it's the same kind of problem. you perhaps just trying to make code a bit more consistent re: beginning/end of strings? This is true too. -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
change strings main window
Hi, Main window says Press enter to boot the selected OS. Problems: a) not all entries are booting an OS (e.g. change colors) b) Grub usually loads a Kernel, not an OS c) (I thought to change because this one): some users maybe doesn't know what OS means Find a patch that re-words it a bit and makes more accurate. -- Carles Pina i Estany http://pinux.info === modified file 'ChangeLog' --- ChangeLog 2010-01-02 15:19:57 + +++ ChangeLog 2010-01-02 23:08:06 + @@ -1,3 +1,7 @@ +2010-01-03 Carles Pina i Estany car...@pina.cat + + * normal/menu_text.c (print_message): Change messages. + 2010-01-02 Colin Watson cjwat...@ubuntu.com * term/i386/pc/at_keyboard.c === modified file 'normal/menu_text.c' --- normal/menu_text.c 2010-01-01 17:58:00 + +++ normal/menu_text.c 2010-01-02 23:08:00 + @@ -214,7 +214,7 @@ entry is highlighted.\n); grub_free (msg_translated); - grub_print_message_indented (_(Press enter to boot the selected OS, \ + grub_print_message_indented (_(Press enter to select an option, \ \'e\' to edit the commands before booting or \'c\' for a command-line.\n), STANDARD_MARGIN, STANDARD_MARGIN); if (nested) @@ -385,7 +385,7 @@ static void print_timeout (int timeout, int offset) { const char *msg = -_(The highlighted entry will be booted automatically in %ds.); +_(The highlighted entry will be selected automatically in %ds.); grub_gotoxy (0, GRUB_TERM_HEIGHT - 3); ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] spaces (label, UUID)
Hi, On Jan/01/2010, Robert Millan wrote: On Mon, Dec 28, 2009 at 02:17:37AM +0100, Carles Pina i Estany wrote: === modified file 'normal/misc.c' --- normal/misc.c 2009-12-20 23:32:15 + +++ normal/misc.c 2009-12-28 01:15:34 + @@ -68,7 +68,10 @@ grub_normal_print_device_info (const cha if (grub_errno == GRUB_ERR_NONE) { if (label grub_strlen (label)) - grub_printf_ (N_(- Label %s), label); + { + grub_putchar (' '); + grub_printf_ (N_(- Label \%s\), label); + } Why not just add a space before the -? Uhm, I guess I know the answer in advance :-) I think that you thought about half of the reasons :-) Carles, we shouldn't avoid changing translatable strings at the cost of making the code bigger or less efficient. It's not hard for translators to reuse the old string. This is half of the reason (and not too bad: this translation will appear as fuzzy so it's not everything lost) The other reason: http://lists.gnu.org/archive/html/grub-devel/2009-12/msg00131.html Avoiding to have trailing spaces helps the translators (they will do less mistakes). Of course makes the code slightly bigger (source code and binary) I notice that you committed it already. Please can you adjust? Yes I can adjust, but could you reconfirm if I should adjust after above message? Thanks, -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH] help command fix (II)
Hello, Some days ago I sent: http://lists.gnu.org/archive/html/grub-devel/2009-12/msg00433.html As Vladimir commented on IRC: patch was not checking how long the strings appears on the screen (multiple-byte chars, etc.) Find attached a new version, measuring the width of the strings. I have tested it adding some long summary in some commands and works fine (apparently at least). Thank you, -- Carles Pina i Estany http://pinux.info === modified file 'ChangeLog' --- ChangeLog 2010-01-01 12:33:45 + +++ ChangeLog 2010-01-01 17:08:20 + @@ -1,3 +1,14 @@ +2010-01-01 Carles Pina i Estany car...@pina.cat + + * commands/help.c: Include `grub/mm.h' and `grub/normal.h'. + (grub_cmd_help): Print the cmd-name before the cmd-summary. Cut the + string using string width. + * normal/menu_text.c (grub_print_message_indented): Use + grub_print_spaces and not print_spaces. + (print_timeout): Likewise. + (print_spaces): Move to... + * include/grub/term.h: ... here. Change the name to grub_print_spaces. + 2010-01-01 Robert Millan rmh.g...@aybabtu.com Import from Gnulib. === modified file 'commands/help.c' --- commands/help.c 2009-12-25 23:50:59 + +++ commands/help.c 2010-01-01 17:06:21 + @@ -22,6 +22,8 @@ #include grub/term.h #include grub/extcmd.h #include grub/i18n.h +#include grub/mm.h +#include grub/normal.h static grub_err_t grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc, @@ -38,19 +40,42 @@ grub_cmd_help (grub_extcmd_t ext __attri if ((cmd-prio GRUB_PRIO_LIST_FLAG_ACTIVE) (cmd-flags GRUB_COMMAND_FLAG_CMDLINE)) { - char description[GRUB_TERM_WIDTH / 2]; - const char* summary_translated = _(cmd-summary); - int desclen = grub_strlen (summary_translated); - - /* 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, summary_translated, - (desclen GRUB_TERM_WIDTH / 2 - 1 - ? desclen : GRUB_TERM_WIDTH / 2 - 1)); + char *command_help; + const char *summary_translated = _(cmd-summary); + grub_uint32_t *unicode_command_help; + grub_uint32_t *unicode_last_position; + + command_help = grub_malloc (grub_strlen (cmd-name) + + sizeof ( ) - 1 + + grub_strlen (summary_translated)); + + grub_sprintf(command_help, %s %s, cmd-name, summary_translated); + + grub_utf8_to_ucs4_alloc (command_help, unicode_command_help, + unicode_last_position); + + while (grub_getstringwidth (unicode_command_help, + unicode_last_position) + (GRUB_TERM_WIDTH / 2) - 2) + { + unicode_last_position--; + } - grub_printf (%s%s, description, (cnt++) % 2 ? \n : ); + grub_print_ucs4 (unicode_command_help, unicode_last_position); + + if ((cnt++) % 2) + { + grub_putchar ('\n'); + } + else + { + grub_print_spaces (GRUB_TERM_WIDTH / 2 - + grub_getstringwidth (unicode_command_help, + unicode_last_position)); + } + + grub_free (command_help); + grub_free (unicode_command_help); } return 0; } === modified file 'include/grub/term.h' --- include/grub/term.h 2009-08-28 13:20:34 + +++ include/grub/term.h 2010-01-01 17:04:10 + @@ -299,6 +299,14 @@ int EXPORT_FUNC(grub_getcursor) (void); void EXPORT_FUNC(grub_refresh) (void); void EXPORT_FUNC(grub_set_more) (int onoff); +static inline void +grub_print_spaces (int number_spaces) +{ + while (--number_spaces = 0) + grub_putchar (' '); +} + + /* For convenience. */ #define GRUB_TERM_ASCII_CHAR(c) ((c) 0xff) === modified file 'normal/menu_text.c' --- normal/menu_text.c 2009-12-27 21:32:52 + +++ normal/menu_text.c 2010-01-01 15:48:11 + @@ -45,14 +45,6 @@ grub_wait_after_message (void) grub_putchar ('\n'); } -static void -print_spaces (int number_spaces) -{ - int i; - for (i = 0; i number_spaces; i++) -grub_putchar (' '); -} - void grub_print_ucs4 (const grub_uint32_t * str, const grub_uint32_t * last_position) @@ -149,7 +141,7 @@ grub_print_message_indented (const char (grub_uint32_t *) last_position : next_new_line + line_len; } - print_spaces (margin_left); + grub_print_spaces (margin_left); grub_print_ucs4 (current_position, next_new_line); next_new_line++; @@ -405,7 +397,7 @@ print_timeout (int timeout, int offset) int posx; posx = grub_getxy() 8; - print_spaces (GRUB_TERM_WIDTH - posx - 1); + grub_print_spaces (GRUB_TERM_WIDTH - posx - 1); grub_gotoxy (GRUB_TERM_CURSOR_X, GRUB_TERM_FIRST_ENTRY_Y + offset); grub_refresh (); @@ -495,7 +487,7 @@ run_menu (grub_menu_t menu, int nested, if (timeout = 0) { grub_gotoxy (0, GRUB_TERM_HEIGHT - 3); - print_spaces (GRUB_TERM_WIDTH - 1
Re: [PATCH] help command fix (II)
Hi, On Jan/01/2010, Carles Pina i Estany wrote: Find attached a new version, measuring the width of the strings. I have After some comments from Vladimir on IRC, committed. -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH] macrofy (multiterm branch)
Hi, Find an attached patch to macrofy pos 8 and pos 0xff in multiter. In my opinion should be macrofied, it's more clear. -- Carles Pina i Estany http://pinux.info === modified file 'include/grub/term.h' --- include/grub/term.h 2009-12-25 02:37:20 + +++ include/grub/term.h 2009-12-30 18:17:55 + @@ -32,6 +32,8 @@ #define GRUB_TERM_ESC '\e' #define GRUB_TERM_TAB '\t' #define GRUB_TERM_BACKSPACE 8 +#define GETX(XY) (XY 8) +#define GETY(XY) (XY 0xff) #ifndef ASM_FILE === modified file 'loader/i386/efi/linux.c' --- loader/i386/efi/linux.c 2009-12-26 21:16:14 + +++ loader/i386/efi/linux.c 2009-12-30 18:19:32 + @@ -700,8 +700,8 @@ grub_cmd_linux (grub_command_t cmd __att if (grub_strcmp (term-name, vga_text) == 0) { grub_uint16_t pos = grub_term_getxy (term); - params-video_cursor_x = pos 8; - params-video_cursor_y = pos 0xff; + params-video_cursor_x = GETX (pos); + params-video_cursor_y = GETY (pos); params-video_width = grub_term_width (term); params-video_height = grub_term_height (term); found = 1; @@ -711,8 +711,8 @@ grub_cmd_linux (grub_command_t cmd __att if (grub_strcmp (term-name, console) == 0) { grub_uint16_t pos = grub_term_getxy (term); - params-video_cursor_x = pos 8; - params-video_cursor_y = pos 0xff; + params-video_cursor_x = GETX (pos); + params-video_cursor_y = GETY (pos); params-video_width = grub_term_width (term); params-video_height = grub_term_height (term); found = 1; === modified file 'loader/i386/ieee1275/linux.c' --- loader/i386/ieee1275/linux.c 2009-12-28 21:06:30 + +++ loader/i386/ieee1275/linux.c 2009-12-30 18:20:17 + @@ -116,8 +116,8 @@ grub_linux_boot (void) if (grub_strcmp (term-name, vga_text) == 0) { grub_uint16_t pos = grub_term_getxy (term); - params-video_cursor_x = pos 8; - params-video_cursor_y = pos 0xff; + params-video_cursor_x = GETX (pos); + params-video_cursor_y = GETY (pos); params-video_width = grub_term_width (term); params-video_height = grub_term_height (term); found = 1; @@ -127,8 +127,8 @@ grub_linux_boot (void) if (grub_strcmp (term-name, console) == 0) { grub_uint16_t pos = grub_term_getxy (term); - params-video_cursor_x = pos 8; - params-video_cursor_y = pos 0xff; + params-video_cursor_x = GETX (pos); + params-video_cursor_y = GETY (pos); params-video_width = grub_term_width (term); params-video_height = grub_term_height (term); found = 1; === modified file 'loader/i386/linux.c' --- loader/i386/linux.c 2009-12-24 23:07:52 + +++ loader/i386/linux.c 2009-12-30 18:18:24 + @@ -554,8 +554,8 @@ grub_linux_boot (void) if (grub_strcmp (term-name, vga_text) == 0) { grub_uint16_t pos = grub_term_getxy (term); - params-video_cursor_x = pos 8; - params-video_cursor_y = pos 0xff; + params-video_cursor_x = GETX (pos); + params-video_cursor_y = GETY (pos); found = 1; } if (!found) @@ -563,8 +563,8 @@ grub_linux_boot (void) if (grub_strcmp (term-name, console) == 0) { grub_uint16_t pos = grub_term_getxy (term); - params-video_cursor_x = pos 8; - params-video_cursor_y = pos 0xff; + params-video_cursor_x = GETX (pos); + params-video_cursor_y = GETY (pos); found = 1; } if (!found) === modified file 'normal/menu_entry.c' --- normal/menu_entry.c 2009-12-25 15:28:31 + +++ normal/menu_entry.c 2009-12-30 18:19:09 + @@ -1098,7 +1098,7 @@ complete (struct screen *screen, int con if (*p) grub_putcode (GRUB_TERM_DISP_RIGHT, screen-terms[i].term); - grub_term_gotoxy (screen-terms[i].term, pos 8, pos 0xFF); + grub_term_gotoxy (screen-terms[i].term, GETX (pos), GETY (pos)); } if (insert) @@ -1132,7 +1132,7 @@ clear_completions (struct per_term_scree grub_putcode ('\n', term_screen-term); } - grub_term_gotoxy (term_screen-term, pos 8, pos 0xFF); + grub_term_gotoxy (term_screen-term, GETX (pos), GETY (pos)); grub_term_refresh (term_screen-term); } === modified file 'term/efi/console.c' --- term/efi/console.c 2009-12-24 23:13:03 + +++ term/efi/console.c 2009-12-30 18:19:46 + @@ -137,7 +137,7 @@ grub_console_checkkey (void) grub_printf (scan_code=%x,unicode_char=%x , (unsigned) key.scan_code, (unsigned) key.unicode_char); - grub_gotoxy (xy 8, xy 0xff); + grub_gotoxy (GETX(xy), GETY(xy)); } break; === modified file 'term/i386/pc/vga.c' --- term/i386/pc/vga.c 2009-06-10 21:04:23 + +++ term/i386/pc/vga.c 2009-12-30 18:27:04 + @@ -379,8 +379,8 @@ grub_vga_putchar (grub_uint32_t c) show = 0; grub_gotoxy (0, 0); - grub_printf ([%u:%u], (unsigned) (pos 8), (unsigned) (pos 0xff)); - grub_gotoxy (pos 8, pos 0xff); + grub_printf ([%u:%u], (unsigned) (GETX (pos)), (unsigned) (GETY (pos)); + grub_gotoxy (GETX (pos), GETY (pos
Re: [PATCH] macrofying
Hi, On Dec/28/2009, Carles Pina i Estany wrote: Attached a patch that macrofies some values. I don't see any reason that was not macrofied. I forgot to mention: multiterm branch improved it in a different way. -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] spaces (label, UUID)
Hi, On Dec/28/2009, Carles Pina i Estany wrote: This patch should fix a small problem that Vladimir spotted and Committed. -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: lib/arg.c: dynamic newline in help
Hi, On Dec/27/2009, Carles Pina i Estany wrote: Until now the options for the commands has been splitted (using a \n) by the developer. if you want to test the patch, check the output of: insmod acpi help acpi before and after the patch. Before (at least with the standard terminal text): there are some lines that doesn't fit in one line and appears not very nice formatted (e.g. no-ebda). With the patch appears like it should appear. -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: lib/arg.c: dynamic newline in help
Hi, Following a suggestion of Vladimir, now it uses GRUB_TERMINAL_WIDTH if it's not compiling in util way. -- Carles Pina i Estany http://pinux.info === modified file 'ChangeLog' --- ChangeLog 2009-12-26 23:43:21 + +++ ChangeLog 2009-12-27 17:06:29 + @@ -1,5 +1,10 @@ 2009-12-27 Carles Pina i Estany car...@pina.cat + * lib/arg.c (AVAILABLE_CHARS_LINE): New macro. + (grub_arg_show_help): Cut the help string dynamically. + +2009-12-27 Carles Pina i Estany car...@pina.cat + * normal/cmdline.c (grub_cmdline_get): Print a space after prompt. * normal/main.c (grub_normal_read_line): Remove a space from the default prompt. === modified file 'lib/arg.c' --- lib/arg.c 2009-12-25 23:50:59 + +++ lib/arg.c 2009-12-27 18:36:58 + @@ -144,7 +144,48 @@ grub_arg_show_help (grub_extcmd_t cmd) } } - const char *doc = _(opt-doc); + char *doc_orig = grub_strdup (_(opt-doc)); + char *doc = doc_orig; + + char* next_newline = doc; + char* line; + char* doc_last = doc + grub_strlen (doc); + #ifndef GRUB_UTIL + const int terminal_width = GRUB_TERM_WIDTH; + #else + const int terminal_width = 80; + #endif + + const int chars_line = terminal_width - 25; + + while (next_newline + chars_line doc_last) + { + line = next_newline; + + /* Move forward. */ + while (*next_newline != '\n' + next_newline - line chars_line + *next_newline != '\0') + { + next_newline++; + } + + /* Move backward. */ + while (*next_newline != '\n' + *next_newline != ' ' next_newline != line + *next_newline != '\0') + { + next_newline--; + } + + *next_newline = '\n'; + if (next_newline == line) + { + break; + } + next_newline++; + } + for (;;) { while (spacing-- 0) @@ -159,6 +200,8 @@ grub_arg_show_help (grub_extcmd_t cmd) doc++; spacing = 4 + 20; } + + grub_free (doc_orig); switch (opt-shortarg) { ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: help command
Hi, On Dec/27/2009, Carles Pina i Estany wrote: I'll fix soon (tonight / tomorrow). a patch idea is attached. Before all summaries was: COMMAND_NAME COMMAND_SUMMARY r1992 removed COMMAND_NAME from the COMMAND_SUMMARY (smaller, not redundant, etc.). But help without arguments was showing only COMMAND_SUMMARY. Now it shows the COMMAND_NAME concatenated with the summary. proposed patch is my natural approach. Alternatively one (tell me if you want) is using grub_memcpy two times (for cmd-name and summary_translated). I just like more the idea to format everything correctly and then copy checking the number of characters used. -- Carles Pina i Estany http://pinux.info === modified file 'ChangeLog' --- ChangeLog 2009-12-26 23:43:21 + +++ ChangeLog 2009-12-27 19:30:55 + @@ -1,5 +1,10 @@ 2009-12-27 Carles Pina i Estany car...@pina.cat + * commands/help.c: Inclue `grub/mm.h'. + (grub_cmd_help): Prepends cmd-name before cmd-summary. + +2009-12-27 Carles Pina i Estany car...@pina.cat + * normal/cmdline.c (grub_cmdline_get): Print a space after prompt. * normal/main.c (grub_normal_read_line): Remove a space from the default prompt. === modified file 'commands/help.c' --- commands/help.c 2009-12-25 23:50:59 + +++ commands/help.c 2009-12-27 19:28:44 + @@ -22,6 +22,7 @@ #include grub/term.h #include grub/extcmd.h #include grub/i18n.h +#include grub/mm.h static grub_err_t grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc, @@ -40,15 +41,22 @@ grub_cmd_help (grub_extcmd_t ext __attri { char description[GRUB_TERM_WIDTH / 2]; const char* summary_translated = _(cmd-summary); - int desclen = grub_strlen (summary_translated); + int desclen = grub_strlen (cmd-name) + grub_strlen ( ) + + grub_strlen (summary_translated) + 1; + + char* help_line = grub_malloc (desclen); + grub_sprintf (help_line, %s %s, cmd-name, summary_translated); + help_line[desclen-1] = ' '; /* 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, summary_translated, + grub_memcpy (description, help_line, (desclen GRUB_TERM_WIDTH / 2 - 1 ? desclen : GRUB_TERM_WIDTH / 2 - 1)); + + grub_free (help_line); grub_printf (%s%s, description, (cnt++) % 2 ? \n : ); } ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH] macrofying
Hi, Attached a patch that macrofies some values. I don't see any reason that was not macrofied. -- Carles Pina i Estany http://pinux.info === modified file 'ChangeLog' --- ChangeLog 2009-12-27 21:32:52 + +++ ChangeLog 2009-12-28 00:10:40 + @@ -1,3 +1,9 @@ +2009-12-28 Carles Pina i Estany car...@pina.cat + + * loader/i386/efi/linux.c (grub_cmd_linux): Use GRUB_TERM_WIDTH and + GRUB_TERM_HEIGHT macros. + * loader/i386/ieee1275/linux.c (grub_linux_boot): Likewise. + 2009-12-27 Vladimir Serbinenko phco...@gmail.com * normal/menu_text.c (grub_print_message_indented): Prevent === modified file 'loader/i386/efi/linux.c' --- loader/i386/efi/linux.c 2009-12-26 23:36:59 + +++ loader/i386/efi/linux.c 2009-12-28 00:09:05 + @@ -697,9 +697,9 @@ grub_cmd_linux (grub_command_t cmd __att params-video_cursor_y = grub_getxy () 0xff; params-video_page = 0; /* ??? */ params-video_mode = grub_efi_system_table-con_out-mode-mode; - params-video_width = (grub_getwh () 8); + params-video_width = GRUB_TERM_WIDTH; params-video_ega_bx = 0; - params-video_height = (grub_getwh () 0xff); + params-video_height = GRUB_TERM_HEIGHT; params-have_vga = 0; params-font_size = 16; /* XXX */ === modified file 'loader/i386/ieee1275/linux.c' --- loader/i386/ieee1275/linux.c 2009-12-26 23:36:59 + +++ loader/i386/ieee1275/linux.c 2009-12-28 00:08:56 + @@ -109,8 +109,8 @@ grub_linux_boot (void) params-cl_magic = GRUB_LINUX_CL_MAGIC; params-cl_offset = GRUB_OFW_LINUX_CL_OFFSET; - params-video_width = (grub_getwh () 8); - params-video_height = (grub_getwh () 0xff); + params-video_width = GRUB_TERM_WIDTH; + params-video_height = GRUB_TERM_HEIGHT; params-font_size = 16; params-ofw_signature = GRUB_LINUX_OFW_SIGNATURE; ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH] spaces (label, UUID)
Hi, This patch should fix a small problem that Vladimir spotted and commented on IRC, plus adds a quotes on the label (looks nicer) and clearer in my opinion. Cheers, -- Carles Pina i Estany http://pinux.info === modified file 'ChangeLog' --- ChangeLog 2009-12-27 21:32:52 + +++ ChangeLog 2009-12-28 01:16:20 + @@ -1,3 +1,8 @@ +2009-12-28 Carles Pina i Estany car...@pina.cat + + * normal/misc.c (grub_normal_print_device_info): Add spaces and double + quotes. + 2009-12-27 Vladimir Serbinenko phco...@gmail.com * normal/menu_text.c (grub_print_message_indented): Prevent === modified file 'normal/misc.c' --- normal/misc.c 2009-12-20 23:32:15 + +++ normal/misc.c 2009-12-28 01:15:34 + @@ -68,7 +68,10 @@ grub_normal_print_device_info (const cha if (grub_errno == GRUB_ERR_NONE) { if (label grub_strlen (label)) - grub_printf_ (N_(- Label %s), label); + { + grub_putchar (' '); + grub_printf_ (N_(- Label \%s\), label); + } grub_free (label); } grub_errno = GRUB_ERR_NONE; @@ -81,6 +84,7 @@ grub_normal_print_device_info (const cha if (grub_errno == GRUB_ERR_NONE) { grub_unixtime2datetime (tm, datetime); + grub_putchar (' '); grub_printf_ (N_(- Last modification time %d-%02d-%02d %02d:%02d:%02d %s), datetime.year, datetime.month, datetime.day, ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
user messages
Hello, Find an attached patch. Linux should be always capitalized. All Linux loaders should have the same message: consistency, better LZMA and less work for translators. If you prefer another string tell me and I'll change. -- Carles Pina i Estany http://pinux.info === modified file 'ChangeLog' --- ChangeLog 2009-12-26 10:01:33 + +++ ChangeLog 2009-12-26 10:16:01 + @@ -1,5 +1,15 @@ 2009-12-27 Carles Pina i Estany car...@pina.cat + * loader/i386/efi/linux.c (GRUB_MOD_INIT): Improve command summary. + * loader/i386/ieee1275/linux.c (GRUB_MOD_INIT): Likewise. + * loader/i386/linux.c (GRUB_MOD_INIT): Likewise. + * loader/i386/pc/linux.c (GRUB_MOD_INIT): Likewise. + * loader/powerpc/ieee1275/linux.c (GRUB_MOD_INIT): Likewise. + * loader/sparc64/ieee1275/linux.c (GRUB_MOD_INIT): Likewise. + * loader/xnu.c (GRUB_MOD_INIT): Likewise. + +2009-12-27 Carles Pina i Estany car...@pina.cat + * efiemu/main.c (GRUB_MOD_INIT): Fix capitalizations and/or full stops. * kern/corecmd.c (grub_register_core_commands): Likewise. === modified file 'loader/i386/efi/linux.c' --- loader/i386/efi/linux.c 2009-12-26 10:01:33 + +++ loader/i386/efi/linux.c 2009-12-26 10:11:47 + @@ -989,9 +989,9 @@ static grub_command_t cmd_linux, cmd_ini GRUB_MOD_INIT(linux) { cmd_linux = grub_register_command (linux, grub_cmd_linux, - 0, Load linux.); + 0, Load a Linux kernel.); cmd_initrd = grub_register_command (initrd, grub_cmd_initrd, - 0, Load initrd.); + 0, Load an initrd.); my_mod = mod; } === modified file 'loader/i386/ieee1275/linux.c' --- loader/i386/ieee1275/linux.c 2009-12-26 10:01:33 + +++ loader/i386/ieee1275/linux.c 2009-12-26 10:12:05 + @@ -276,9 +276,9 @@ static grub_command_t cmd_linux, cmd_ini GRUB_MOD_INIT(linux) { cmd_linux = grub_register_command (linux, grub_cmd_linux, - 0, Load linux.); + 0, Load a Linux kernel.); cmd_initrd = grub_register_command (initrd, grub_cmd_initrd, - 0, Load initrd.); + 0, Load an initrd.); my_mod = mod; } === modified file 'loader/i386/linux.c' --- loader/i386/linux.c 2009-12-26 10:01:33 + +++ loader/i386/linux.c 2009-12-26 10:10:15 + @@ -982,9 +982,9 @@ static grub_command_t cmd_linux, cmd_ini GRUB_MOD_INIT(linux) { cmd_linux = grub_register_command (linux, grub_cmd_linux, - 0, Load linux.); + 0, Load a Linux kernel.); cmd_initrd = grub_register_command (initrd, grub_cmd_initrd, - 0, Load initrd.); + 0, Load an initrd.); my_mod = mod; } === modified file 'loader/i386/pc/linux.c' --- loader/i386/pc/linux.c 2009-12-26 10:01:33 + +++ loader/i386/pc/linux.c 2009-12-26 10:12:34 + @@ -383,10 +383,10 @@ GRUB_MOD_INIT(linux16) { cmd_linux = grub_register_command (linux16, grub_cmd_linux, - 0, Load linux.); + 0, Load a Linux kernel.); cmd_initrd = grub_register_command (initrd16, grub_cmd_initrd, - 0, Load initrd.); + 0, Load an initrd.); my_mod = mod; } === modified file 'loader/powerpc/ieee1275/linux.c' --- loader/powerpc/ieee1275/linux.c 2009-12-26 10:01:33 + +++ loader/powerpc/ieee1275/linux.c 2009-12-26 10:12:56 + @@ -349,7 +349,7 @@ static grub_command_t cmd_linux, cmd_ini GRUB_MOD_INIT(linux) { cmd_linux = grub_register_command (linux, grub_cmd_linux, - 0, Load a linux kernel.); + 0, Load a Linux kernel.); cmd_initrd = grub_register_command (initrd, grub_cmd_initrd, 0, Load an initrd.); my_mod = mod; === modified file 'loader/sparc64/ieee1275/linux.c' --- loader/sparc64/ieee1275/linux.c 2009-12-26 10:01:33 + +++ loader/sparc64/ieee1275/linux.c 2009-12-26 10:13:17 + @@ -516,7 +516,7 @@ GRUB_MOD_INIT(linux) fetch_translations (); cmd_linux = grub_register_command (linux, grub_cmd_linux, - 0, Load a linux kernel.); + 0, Load a Linux kernel.); cmd_initrd = grub_register_command (initrd, grub_cmd_initrd, 0, Load an initrd.); my_mod = mod; === modified file 'loader/xnu.c' --- loader/xnu.c 2009-12-26 10:01:33 + +++ loader/xnu.c 2009-12-26 10:09:38 + @@ -1404,9 +1404,9 @@ static grub_command_t cmd_kextdir, cmd_r GRUB_MOD_INIT(xnu) { cmd_kernel = grub_register_command (xnu_kernel, grub_cmd_xnu_kernel, 0, - Load a xnu kernel.); + Load a XNU kernel.); cmd_kernel64 = grub_register_command (xnu_kernel64, grub_cmd_xnu_kernel64, - 0, Load a 64-bit xnu kernel.); + 0, Load a 64-bit XNU kernel.); cmd_mkext = grub_register_command (xnu_mkext, grub_cmd_xnu_mkext, 0, Load XNU extension package.); cmd_kext = grub_register_command (xnu_kext, grub_cmd_xnu_kext, 0, ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
patch to compile video/readers/* with test
Hi, Find an attached patch that fix the compilation of video/readers/* when DEBUG is enabled. If ok I would commit. Thanks, -- Carles Pina i Estany http://pinux.info === modified file 'ChangeLog' --- ChangeLog 2009-12-26 10:01:33 + +++ ChangeLog 2009-12-26 10:42:57 + @@ -1,5 +1,23 @@ 2009-12-27 Carles Pina i Estany car...@pina.cat + * video/readers/jpeg.c (cmd): Declare. + (grub_cmd_jpegtest): Use `grub_command_t' type. + (GRUB_MOD_INIT): Fix arguments passed to `grub_register_command'. Assign + to `cmd'. + (GRUB_MOD_FINI): Use `cmd' to unregister. + * video/readers/png.c (cmd): Declare. + (grub_cmd_pngtest): Use `grub_command_t' type. + (GRUB_MOD_INIT): Fix arguments passed to `grub_register_command'. Assign + to `cmd'. + (GRUB_MOD_FINI): Use `cmd' to unregister. + * video/readers/tga.c (cmd): Declare. + (grub_cmd_tgatest): Use `grub_command_t' type. + (GRUB_MOD_INIT): Fix arguments passed to `grub_register_command'. Assign + to `cmd'. + (GRUB_MOD_FINI): Use `cmd' to unregister. + +2009-12-27 Carles Pina i Estany car...@pina.cat + * efiemu/main.c (GRUB_MOD_INIT): Fix capitalizations and/or full stops. * kern/corecmd.c (grub_register_core_commands): Likewise. === modified file 'video/readers/jpeg.c' --- video/readers/jpeg.c 2009-12-25 23:50:59 + +++ video/readers/jpeg.c 2009-12-26 10:35:09 + @@ -54,6 +54,10 @@ static const grub_uint8_t jpeg_zigzag_or 53, 60, 61, 54, 47, 55, 62, 63 }; +#ifdef JPEG_DEBUG +static grub_command_t cmd; +#endif + typedef int jpeg_data_unit_t[64]; struct grub_jpeg_data @@ -695,8 +699,8 @@ grub_video_reader_jpeg (struct grub_vide #if defined(JPEG_DEBUG) static grub_err_t -grub_cmd_jpegtest (struct grub_arg_list *state __attribute__ ((unused)), - int argc, char **args) +grub_cmd_jpegtest (grub_command_t cmd __attribute__ ((unused)), + int argc, char **args) { struct grub_video_bitmap *bitmap = 0; @@ -730,16 +734,16 @@ GRUB_MOD_INIT (video_reader_jpeg) grub_video_bitmap_reader_register (jpg_reader); grub_video_bitmap_reader_register (jpeg_reader); #if defined(JPEG_DEBUG) - grub_register_command (jpegtest, grub_cmd_jpegtest, - GRUB_COMMAND_FLAG_BOTH, FILE, - Tests loading of JPEG bitmap., 0); + cmd = grub_register_command (jpegtest, grub_cmd_jpegtest, + FILE, + Tests loading of JPEG bitmap.); #endif } -GRUB_MOD_FINI (video_reader_jpeg) +GRUB_MOD_FINI (grub_cmd_jpegtest) { #if defined(JPEG_DEBUG) - grub_unregister_command (jpegtest); + grub_unregister_command (cmd); #endif grub_video_bitmap_reader_unregister (jpeg_reader); grub_video_bitmap_reader_unregister (jpg_reader); === modified file 'video/readers/png.c' --- video/readers/png.c 2009-12-25 23:50:59 + +++ video/readers/png.c 2009-12-26 10:40:10 + @@ -73,6 +73,10 @@ #define DEFLATE_HUFF_LEN 16 +#ifdef PNG_DEBUG +static grub_command_t cmd; +#endif + struct huff_table { int *values, *maxval, *offset; @@ -866,7 +870,7 @@ grub_video_reader_png (struct grub_video #if defined(PNG_DEBUG) static grub_err_t -grub_cmd_pngtest (struct grub_arg_list *state __attribute__ ((unused)), +grub_cmd_pngtest (grub_command_t cmd __attribute__ ((unused)), int argc, char **args) { struct grub_video_bitmap *bitmap = 0; @@ -894,16 +898,16 @@ GRUB_MOD_INIT (video_reader_png) { grub_video_bitmap_reader_register (png_reader); #if defined(PNG_DEBUG) - grub_register_command (pngtest, grub_cmd_pngtest, - GRUB_COMMAND_FLAG_BOTH, FILE, - Tests loading of PNG bitmap., 0); + cmd = grub_register_command (pngtest, grub_cmd_pngtest, + FILE, + Tests loading of PNG bitmap.); #endif } GRUB_MOD_FINI (video_reader_png) { #if defined(PNG_DEBUG) - grub_unregister_command (pngtest); + grub_unregister_command (cmd); #endif grub_video_bitmap_reader_unregister (png_reader); } === modified file 'video/readers/tga.c' --- video/readers/tga.c 2009-12-25 23:50:59 + +++ video/readers/tga.c 2009-12-26 10:39:37 + @@ -29,6 +29,7 @@ #if defined(TGA_DEBUG) #define dump_int_field(x) grub_printf( #x = %d (0x%04x)\n, x, x); +static grub_command_t cmd; #endif enum @@ -452,7 +453,7 @@ grub_video_reader_tga (struct grub_video #if defined(TGA_DEBUG) static grub_err_t -grub_cmd_tgatest (struct grub_arg_list *state __attribute__ ((unused)), +grub_cmd_tgatest (grub_command_t cmd __attribute__ ((unused)), int argc, char **args) { struct grub_video_bitmap *bitmap = 0; @@ -480,15 +481,15 @@ GRUB_MOD_INIT(video_reader_tga) { grub_video_bitmap_reader_register (tga_reader); #if defined(TGA_DEBUG) - grub_register_command (tgatest, grub_cmd_tgatest, GRUB_COMMAND_FLAG_BOTH, - FILE, Tests loading of TGA bitmap., 0); + cmd = grub_register_command (tgatest, grub_cmd_tgatest, + FILE, Tests loading of TGA bitmap.); #endif } GRUB_MOD_FINI(video_reader_tga) { #if defined(TGA_DEBUG
Re: patch to compile video/readers/* with debug
Correct Subject: is with debug (not with test) -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: patch to compile video/readers/* with test
Hi, On Dec/26/2009, Carles Pina i Estany wrote: Find an attached patch that fix the compilation of video/readers/* when DEBUG is enabled. validated in IRC, pushing now -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: user messages
Hi, On Dec/26/2009, Robert Millan wrote: On Sat, Dec 26, 2009 at 11:20:27AM +0100, Carles Pina i Estany wrote: cmd_linux = grub_register_command (linux, grub_cmd_linux, -0, Load linux.); +0, Load a Linux kernel.); The construct Linux kernel is very ambigous because it's not clear if it means the kernel known as Linux or the kernel of Linux. Some people missinterpret it as the kernel of Linux, leading to the long-standing confusion you probably heard about (but I'll paste a link anyway, for the sake of everyone else ;-)): http://www.gnu.org/gnu/linux-and-gnu.html yeap I heard. When I was writig that I was thinking it. I was interpreting as: From the available kernels, load a Linux one.. Like having multiple kernels and loading a Linux one. Never mind, it's ambigous. But I agree it should be capitalized. Please make that Load Linux.. done (see attached patch). For consistency, these could read Load XNU.. If that's too confusing, maybe Load XNU (kernel of Darwin) or something like that. Vladimir what do you think? I send attached a new patch. Let me to comment here the relevant changes against the previous patch: === modified file 'loader/i386/bsd.c' --- loader/i386/bsd.c 2009-12-26 10:01:33 + +++ loader/i386/bsd.c 2009-12-26 17:38:12 + @@ -1280,15 +1280,15 @@ GRUB_MOD_INIT (bsd) { cmd_freebsd = grub_register_extcmd (kfreebsd, grub_cmd_freebsd, GRUB_COMMAND_FLAG_BOTH, - FILE, Load kernel of FreeBSD., + FILE, Load FreeBSD kernel., freebsd_opts); cmd_openbsd = grub_register_extcmd (kopenbsd, grub_cmd_openbsd, GRUB_COMMAND_FLAG_BOTH, - FILE, Load kernel of OpenBSD., + FILE, Load OpenBSD kernel., openbsd_opts); cmd_netbsd = grub_register_extcmd (knetbsd, grub_cmd_netbsd, GRUB_COMMAND_FLAG_BOTH, -FILE, Load kernel of NetBSD., +FILE, Load NetBSD kernel., netbsd_opts); how it sounds? maybe easier to read (if correct) Load NetBSD kernel. than other way? XNU now is: cmd_kernel = grub_register_command (xnu_kernel, grub_cmd_xnu_kernel, 0, - Load a xnu kernel.); + Load XNU.); cmd_kernel64 = grub_register_command (xnu_kernel64, grub_cmd_xnu_kernel64, - 0, Load a 64-bit xnu kernel.); + 0, Load 64-bit XNU.); cmd_mkext = grub_register_command (xnu_mkext, grub_cmd_xnu_mkext, 0, Load XNU extension package.); cmd_kext = grub_register_command (xnu_kext, grub_cmd_xnu_kext, 0, Vladimir, would you change something? Thanks, -- Carles Pina i Estany http://pinux.info === modified file 'ChangeLog' --- ChangeLog 2009-12-26 11:08:22 + +++ ChangeLog 2009-12-26 17:34:40 + @@ -1,5 +1,15 @@ 2009-12-26 Carles Pina i Estany car...@pina.cat + * loader/i386/efi/linux.c (GRUB_MOD_INIT): Improve command summary. + * loader/i386/ieee1275/linux.c (GRUB_MOD_INIT): Likewise. + * loader/i386/linux.c (GRUB_MOD_INIT): Likewise. + * loader/i386/pc/linux.c (GRUB_MOD_INIT): Likewise. + * loader/powerpc/ieee1275/linux.c (GRUB_MOD_INIT): Likewise. + * loader/sparc64/ieee1275/linux.c (GRUB_MOD_INIT): Likewise. + * loader/xnu.c (GRUB_MOD_INIT): Likewise. + +2009-12-26 Carles Pina i Estany car...@pina.cat + * video/readers/jpeg.c (cmd): Declare. (grub_cmd_jpegtest): Use `grub_command_t' type. (GRUB_MOD_INIT): Fix arguments passed to `grub_register_command'. @@ -16,7 +26,7 @@ Assign to `cmd'. (GRUB_MOD_FINI): Use `cmd' to unregister. -2009-12-26 Carles Pina i Estany car...@pina.cat +2009-12-27 Carles Pina i Estany car...@pina.cat * efiemu/main.c (GRUB_MOD_INIT): Fix capitalizations and/or full stops. === modified file 'loader/i386/bsd.c' --- loader/i386/bsd.c 2009-12-26 10:01:33 + +++ loader/i386/bsd.c 2009-12-26 17:38:12 + @@ -1280,15 +1280,15 @@ GRUB_MOD_INIT (bsd) { cmd_freebsd = grub_register_extcmd (kfreebsd, grub_cmd_freebsd, GRUB_COMMAND_FLAG_BOTH, - FILE, Load kernel of FreeBSD., + FILE, Load FreeBSD kernel., freebsd_opts); cmd_openbsd = grub_register_extcmd (kopenbsd, grub_cmd_openbsd, GRUB_COMMAND_FLAG_BOTH, - FILE, Load kernel of OpenBSD., + FILE, Load OpenBSD kernel., openbsd_opts); cmd_netbsd = grub_register_extcmd (knetbsd, grub_cmd_netbsd, GRUB_COMMAND_FLAG_BOTH, - FILE, Load kernel of NetBSD., + FILE, Load NetBSD kernel
Re: regression fix
Hi, On Dec/26/2009, Robert Millan wrote: On Sat, Dec 26, 2009 at 01:35:53AM +0100, Carles Pina i Estany wrote: Hi, Commit 1949 introduced a bug using TAB due a miss-understanding that I had with the code. Oh, good to know. I was wondering why TAB expansion did these weird things ;-) Sorry for the inconvenience :-) Pushing now. -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
lib/arg.c: dynamic newline in help
Hello, Until now the options for the commands has been splitted (using a \n) by the developer. For example, commands/hdparm.c: static const struct grub_arg_option options[] = { {apm, 'B', 0, Set Advanced Power Management\n (1=low, ..., 254=high, 255=off)., 0, ARG_TYPE_INT}, This is a problem for the translations: translators should be aware that they need to cut the string after some number of characters, or will not appear correctly formatted. Attached patch splits it dynamically. Note: the attached patch goes forward and then backward because some strings, like above one, must have a \n to split some lines. But other strings could be just be too long and could not have the \n line. The number of characters per line is fixed as a constant because lib/argc.c doesn't know anything about consoles. If I remember correctly is used in two places: form help command and fstest. I think that the attached solution is good enough for the current status. I implemented it using another approach and changed to the current one, so feel free to tell me any problem or things that you would improve. My limited tests has been fine. I think that after comitting it I will be able to gettext all options strings. Thanks, -- Carles Pina i Estany http://pinux.info === modified file 'ChangeLog' --- ChangeLog 2009-12-26 23:43:21 + +++ ChangeLog 2009-12-27 00:08:20 + @@ -1,5 +1,10 @@ 2009-12-27 Carles Pina i Estany car...@pina.cat + * lib/arg.c (AVAILABLE_CHARS_LINE): New macro. + (grub_arg_show_help): Cut the help string dynamically. + +2009-12-27 Carles Pina i Estany car...@pina.cat + * normal/cmdline.c (grub_cmdline_get): Print a space after prompt. * normal/main.c (grub_normal_read_line): Remove a space from the default prompt. === modified file 'lib/arg.c' --- lib/arg.c 2009-12-25 23:50:59 + +++ lib/arg.c 2009-12-27 00:08:27 + @@ -28,6 +28,8 @@ #define SHORT_ARG_HELP -100 #define SHORT_ARG_USAGE -101 +#define AVAILABLE_CHARS_LINE (80 - 25) + static const struct grub_arg_option help_options[] = { {help, SHORT_ARG_HELP, 0, @@ -144,7 +146,41 @@ grub_arg_show_help (grub_extcmd_t cmd) } } - const char *doc = _(opt-doc); + char *doc_orig = grub_strdup (_(opt-doc)); + char *doc = doc_orig; + + char* next_newline = doc; + char* line; + char* doc_last = doc + grub_strlen (doc); + + while (next_newline + AVAILABLE_CHARS_LINE doc_last) + { + line = next_newline; + + /* Move forward. */ + while (*next_newline != '\n' + next_newline - line AVAILABLE_CHARS_LINE + *next_newline != '\0') + { + next_newline++; + } + + /* Move backward. */ + while (*next_newline != '\n' + *next_newline != ' ' next_newline != line + *next_newline != '\0') + { + next_newline--; + } + + *next_newline = '\n'; + if (next_newline == line) + { + break; + } + next_newline++; + } + for (;;) { while (spacing-- 0) @@ -159,6 +195,8 @@ grub_arg_show_help (grub_extcmd_t cmd) doc++; spacing = 4 + 20; } + + grub_free (doc_orig); switch (opt-shortarg) { ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
gettext: help commands
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 2009-12
Re: gettext: help commands
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
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
gettext: lib/arg.c
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
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: gettext: print_timeout
Hi, On Dec/24/2009, Robert Millan wrote: On Sun, Dec 13, 2009 at 01:31:55AM +, Carles Pina i Estany wrote: If ok I would commit. Was this checked in? ISTR having OKed it on IRC, but I don't see it in ChangeLog. it's already applied but not in the way that I was suggesting in the patch. It's a commit from date 2009-12-19 (first one of that day). (print_timeout): Use `print_message_indented' to print the message. Deletes `second_stage' parameter. because print_timeout doesn't need the utf8_to_ucs4 code, this code is inside prprint_message_indented. If some other function will need to use this code I will factorize. (I could factorize now but then we will have an extra call to one function, etc.) -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: grub_error messages
Hi, On Dec/22/2009, Vladimir '??-coder/phcoder' Serbinenko wrote: Jordi Mallach wrote: On Mon, Dec 21, 2009 at 10:19:16PM +, Carles Pina i Estany wrote: b) At beginning I thought that we would not gettext error messages, but I see that lot of these messages appears to the end user. Do we gettext using N_( ) and then where it's printed I use _( ) ? I would say yes. No! Don't use any of N_() or _() if the message isn't meant to be translated. If it's extracted into the pot file but then it's not used by GRUB (not being marked with the necessary gettext call), it's a waste of time for translators, of course. Jordi, I think you misunderstand. What Carles propose is to do real gettext call in grub_error and not before calling it. We already use N_ for this purpose. Vladimir: you got my point. In my mail I mixed a bit two messages: a) Asking confirmation that we will translate that messages (that my first thought was not needed but then I see that appears more than I was thinking) b) Implementation. Vladimir and everybody: I think that these strings are printed by grub_print_error (void), (kern/err.c), in this way: grub_err_printf (error: %s\n, grub_errmsg); so we should NOT capitalise the message strings (in English, after colon is not capitalised). Plus I'm thinking to do: grub_err_printf (error: %s.\n, _(grub_errmsg)); So the . is not part of each string and we save some bytes. What do you think? I haven't tested what I said above... -- 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: commands/*
I've committed the patch. Notes: On Dec/21/2009, Vladimir '??-coder/phcoder' Serbinenko wrote: === modified file 'commands/blocklist.c' --- commands/blocklist.c 2009-06-10 21:04:23 + +++ commands/blocklist.c 2009-12-21 00:09:02 + @@ -87,7 +87,7 @@ grub_cmd_blocklist (grub_command_t cmd _ if (! file-device-disk) return grub_error (GRUB_ERR_BAD_DEVICE, -this command is available only for disk devices.); +this command is available only for disk devices); Capitalisation and full stop I'll talk about this in a new thread. cmd = grub_register_command (halt, grub_cmd_halt, -0, halts the computer. This command does not +0, Halts the computer. This command does not work on all firmware.); I would rather say On *every* firmware. I followed Watson suggestion static const struct grub_arg_option options[] = { -{file, 'f', 0, specify filename, 0, ARG_TYPE_PATHNAME}, +{file, 'f', 0, Specify filename., 0, ARG_TYPE_PATHNAME}, Filename for what? I'll add a comment when I will gettextizze it. -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
grub_error messages
Hi, This comes from gettext: commands/* thread, but I feel that it's already far from gettext :-) Doing, in Grub: grep grub_error commands/* I would say that there are more strings without capitalization and without full stop than with. Then, two questions: a) How we want these strings? I'll do a patch, but I prefer to agree before b) At beginning I thought that we would not gettext error messages, but I see that lot of these messages appears to the end user. Do we gettext using N_( ) and then where it's printed I use _( ) ? I would say yes. Thanks, -- 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: normal/*
Hi, Same patch moving STANDARD_MARGIN to an include file and using it in normal/main.c. -- Carles Pina i Estany http://pinux.info === modified file 'ChangeLog' --- ChangeLog 2009-12-19 23:00:30 + +++ ChangeLog 2009-12-20 12:10:46 + @@ -1,3 +1,33 @@ +2009-12-20 Carles Pina i Estany car...@pina.cat + + * include/grub/auth.h (GRUB_GET_PASSWORD): Remove space from string. + * include/grub/normal.h (STANDARD_MARGIN): New macro, moved from + menu_text.c. + (grub_utf8_to_ucs4_alloc): Fix indentation. + (grub_print_ucs4): Likewise. + (grub_getstringwidth): Likewise. + (print_message_indented): New declaration. + * normal/auth.c: Include `grub/i18n.h'. + (grub_auth_check_authentication): Gettexttize string. + * normal/cmdline.c (grub_cmdline_get): Add space. + * normal/color.c: Include `grub/i18n.h'. + (grub_parse_color_name_pair): Gettexttize strings. + * normal/main.c (grub_normal_reader_init): Cleanup gettexttized + string (use `print_message_indented'). + (grub_normal_read_line): Remove space. + * normal/menu_text.c (STANDARD_MARGIN): Moved from here to + `include/grub/normal.h'. + (print_message_indented): Renamed to ... + (grub_print_message_indented): ... this. Remove `static' qualifer (now + used in normal/main.c). + (print_message): Use `grub_print_message_indented' instead of + `print_message_indented'. + (print_timeout): Likewise. + * normal/misc.c: Include `grub/term.h' and `grub/i18n.h'. + (grub_normal_print_device_info): Gettexttize strings. Replace + grub_printf by grub_putchar. + * po/POTFILES: Add `auth.c', `color.c' and `misc.c'. + 2009-12-19 Carles Pina i Estany car...@pina.cat * include/grub/normal.h (grub_utf8_to_ucs4): New declaration. === modified file 'include/grub/auth.h' --- include/grub/auth.h 2009-08-24 23:55:06 + +++ include/grub/auth.h 2009-12-19 23:06:06 + @@ -22,7 +22,7 @@ /* Macros for indistinguishibility. */ #define GRUB_ACCESS_DENIED grub_error (GRUB_ERR_ACCESS_DENIED, Access denied.) -#define GRUB_GET_PASSWORD(string, len) grub_cmdline_get (Enter password: , \ +#define GRUB_GET_PASSWORD(string, len) grub_cmdline_get (Enter password:, \ string, len, \ '*', 0, 0) === modified file 'include/grub/normal.h' --- include/grub/normal.h 2009-12-19 23:00:30 + +++ include/grub/normal.h 2009-12-20 12:07:19 + @@ -30,6 +30,9 @@ /* The maximum size of a command-line. */ #define GRUB_MAX_CMDLINE 1600 +/* The standard left and right margin for some messages. */ +#define STANDARD_MARGIN 6 + /* The type of a completion item. */ enum grub_completion_type { @@ -74,11 +77,13 @@ void grub_parse_color_name_pair (grub_ui /* Defined in `menu_text.c'. */ void grub_wait_after_message (void); int grub_utf8_to_ucs4_alloc (const char *msg, grub_uint32_t **unicode_msg, - grub_uint32_t **last_position); + grub_uint32_t **last_position); void grub_print_ucs4 (const grub_uint32_t * str, - const grub_uint32_t * last_position); + const grub_uint32_t * last_position); grub_ssize_t grub_getstringwidth (grub_uint32_t * str, - const grub_uint32_t * last_position); + const grub_uint32_t * last_position); +void grub_print_message_indented (const char *msg, int margin_left, + int margin_right); /* Defined in `handler.c'. */ void read_handler_list (void); === modified file 'normal/auth.c' --- normal/auth.c 2009-11-09 14:30:47 + +++ normal/auth.c 2009-12-19 23:06:06 + @@ -23,6 +23,7 @@ #include grub/env.h #include grub/normal.h #include grub/time.h +#include grub/i18n.h struct grub_auth_user { @@ -237,7 +238,7 @@ grub_auth_check_authentication (const ch return GRUB_ERR_NONE; } - if (!grub_cmdline_get (Enter username: , login, sizeof (login) - 1, + if (!grub_cmdline_get (_(Enter username:), login, sizeof (login) - 1, 0, 0, 0)) goto access_denied; === modified file 'normal/cmdline.c' --- normal/cmdline.c 2009-08-28 13:25:10 + +++ normal/cmdline.c 2009-12-19 23:06:06 + @@ -334,7 +334,7 @@ grub_cmdline_get (const char *prompt, ch if (restore) { /* Restore the prompt. */ - grub_printf (\n%s%s, prompt, buf); + grub_printf (\n%s %s, prompt, buf); xpos = plen; ystart = ypos = (grub_getxy () 0xFF); } === modified file 'normal/color.c' --- normal/color.c 2008-03-26 13:01:02 + +++ normal/color.c 2009-12-19 23:06:06 + @@ -20,6 +20,7 @@ #include grub/mm.h #include grub/normal.h #include grub/term.h +#include grub/i18n.h /* Borrowed from GRUB Legacy */ static char *color_list[16] = @@ -76,7 +77,7 @@ grub_parse_color_name_pair (grub_uint8_t bg_name = grub_strchr (fg_name, '/'); if (bg_name == NULL) { - grub_printf (Warning: syntax error (missing slash) in `%s'\n, fg_name); + grub_printf_ (N_(Warning: syntax error (missing slash) in `%s'\n), fg_name); grub_wait_after_message (); goto free_and_return; } @@ -85,13 +86,13 @@ grub_parse_color_name_pair (grub_uint8_t
Re: gettext: normal/*
Hi, On Dec/20/2009, Carles Pina i Estany wrote: Can someone take a look in the patch again? Done in IRC. Thanks, -- 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: version string in normal/main.c
Hi, On Dec/19/2009, Carles Pina i Estany wrote: On Dec/19/2009, Carles Pina i Estany wrote: Something to improve before committing? when this will be reviewed and committed I will adapt (some things has changed) the last part of normal/* files . I sent a week ago aprox. but needs some changes because it conflicts. After that I will do other changes in commands/*, and this is mainly all for Grub2 loader gettext. I'm sure that there are other strings that I will keep doing but at least from the standard user point of view is quite gettextizzed. Then I'll do some documentation about how to test, more testing using gfxterm, update the .pot in TP and keep working with the utils part. As Robert pointed should be done soon so translators can translate, review, spot some deficiencies and sooner better than later. Cheers, -- 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: version string in normal/main.c
Hi, On Dec/19/2009, Carles Pina i Estany wrote: Hi, On Dec/19/2009, Carles Pina i Estany wrote: Something to improve before committing? New patch with a missing grub_free. reviewed in IRC and committed. -- 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: normal/*
Hi, On Dec/07/2009, Carles Pina i Estany wrote: IME, if it's not difficult to get rid of it, it better to do it for safety, because it's a common translator mistake. I will remove the spaces. Only in one place is not straight but it's not difficult. Done in the attached patch. Can someone take a look in the patch again? It's the same than previously in this thread but with some change (added grub_ in a exported function) and in grub_normal_print_device_info I've changed some messages like: - grub_printf (, Label %s, label); + grub_printf_ (N_(- Label %s), label); - grub_printf (, Last modification time %d-%02d-%02d - %02d:%02d:%02d %s, + grub_printf_ (N_(- Last modification time %d-%02d-%02d + %02d:%02d:%02d %s), using - instead of , makes it easier for the translators because it doesn't pretend to be a sentence but only different items in an enumeration. Thanks, -- Carles Pina i Estany http://pinux.info === modified file 'ChangeLog' --- ChangeLog 2009-12-19 23:00:30 + +++ ChangeLog 2009-12-20 01:35:50 + @@ -1,3 +1,29 @@ +2009-12-20 Carles Pina i Estany car...@pina.cat + + * include/grub/auth.h (GRUB_GET_PASSWORD): Remove space from string. + * include/grub/normal.h (grub_utf8_to_ucs4_alloc): Fix indentation. + (grub_print_ucs4): Likewise. + (grub_getstringwidth): Likewise. + (print_message_indented): New declaration. + * normal/auth.c: Include `grub/i18n.h'. + (grub_auth_check_authentication): Gettexttize string. + * normal/cmdline.c (grub_cmdline_get): Add space. + * normal/color.c: Include `grub/i18n.h'. + (grub_parse_color_name_pair): Gettexttize strings. + * normal/main.c (grub_normal_reader_init): Cleanup gettexttized + string (use `print_message_indented'). + (grub_normal_read_line): Remove space. + * normal/menu_text.c (print_message_indented): Renamed to ... + (grub_print_message_indented): ... this. Remove `static' qualifer (now + used in normal/main.c). + (print_message): Use `grub_print_message_indented' instead of + `print_message_indented'. + (print_timeout): Likewise. + * normal/misc.c: Include `grub/term.h' and `grub/i18n.h'. + (grub_normal_print_device_info): Gettexttize strings. Replace + grub_printf by grub_putchar. + * po/POTFILES: Add `auth.c', `color.c' and `misc.c'. + 2009-12-19 Carles Pina i Estany car...@pina.cat * include/grub/normal.h (grub_utf8_to_ucs4): New declaration. === modified file 'include/grub/auth.h' --- include/grub/auth.h 2009-08-24 23:55:06 + +++ include/grub/auth.h 2009-12-19 23:06:06 + @@ -22,7 +22,7 @@ /* Macros for indistinguishibility. */ #define GRUB_ACCESS_DENIED grub_error (GRUB_ERR_ACCESS_DENIED, Access denied.) -#define GRUB_GET_PASSWORD(string, len) grub_cmdline_get (Enter password: , \ +#define GRUB_GET_PASSWORD(string, len) grub_cmdline_get (Enter password:, \ string, len, \ '*', 0, 0) === modified file 'include/grub/normal.h' --- include/grub/normal.h 2009-12-19 23:00:30 + +++ include/grub/normal.h 2009-12-20 01:33:53 + @@ -74,11 +74,13 @@ void grub_parse_color_name_pair (grub_ui /* Defined in `menu_text.c'. */ void grub_wait_after_message (void); int grub_utf8_to_ucs4_alloc (const char *msg, grub_uint32_t **unicode_msg, - grub_uint32_t **last_position); + grub_uint32_t **last_position); void grub_print_ucs4 (const grub_uint32_t * str, - const grub_uint32_t * last_position); + const grub_uint32_t * last_position); grub_ssize_t grub_getstringwidth (grub_uint32_t * str, - const grub_uint32_t * last_position); + const grub_uint32_t * last_position); +void grub_print_message_indented (const char *msg, int margin_left, + int margin_right); /* Defined in `handler.c'. */ void read_handler_list (void); === modified file 'normal/auth.c' --- normal/auth.c 2009-11-09 14:30:47 + +++ normal/auth.c 2009-12-19 23:06:06 + @@ -23,6 +23,7 @@ #include grub/env.h #include grub/normal.h #include grub/time.h +#include grub/i18n.h struct grub_auth_user { @@ -237,7 +238,7 @@ grub_auth_check_authentication (const ch return GRUB_ERR_NONE; } - if (!grub_cmdline_get (Enter username: , login, sizeof (login) - 1, + if (!grub_cmdline_get (_(Enter username:), login, sizeof (login) - 1, 0, 0, 0)) goto access_denied; === modified file 'normal/cmdline.c' --- normal/cmdline.c 2009-08-28 13:25:10 + +++ normal/cmdline.c 2009-12-19 23:06:06 + @@ -334,7 +334,7 @@ grub_cmdline_get (const char *prompt, ch if (restore) { /* Restore the prompt. */ - grub_printf (\n%s%s, prompt, buf); + grub_printf (\n%s %s, prompt, buf); xpos = plen; ystart = ypos = (grub_getxy () 0xFF); } === modified file 'normal/color.c' --- normal/color.c 2008-03-26 13:01:02 + +++ normal/color.c 2009-12-19 23:06:06 + @@ -20,6 +20,7 @@ #include grub/mm.h #include
Re: Unittests
Hi, On Dec/17/2009, BVK Chaitanya wrote: I attached a new patch, which has an example gettext_1.in testcase -- it doesn't yet do what you wanted, but is the starter. Let me know your comments. When I will check I will tell you something :-) (I will do it in some days/during holidays...) Thanks, -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
gettext: version string in normal/main.c
Hi, I've gettextitzzed the version string. Something to improve before committing? It's all right? Thanks, -- Carles Pina i Estany http://pinux.info === modified file 'ChangeLog' --- ChangeLog 2009-12-19 00:05:41 + +++ ChangeLog 2009-12-19 01:27:34 + @@ -1,5 +1,18 @@ 2009-12-19 Carles Pina i Estany car...@pina.cat + * include/grub/normal.h (utf8_to_ucs4): New declaration. + (grub_print_ucs4): Likewise. + (getstringwidth): Likewise. + * normal/main.c (grub_normal_init_page): Gettextize version string. + * normal/menu_text.c (utf8_to_ucs4): New declaration. + (getstringwidth): Remove `static' qualifier (now used in + normal/main.c). Use `utf8_to_ucs4'. + (grub_print_ucs4): Remove `static' qualifer (now used in + normal/main.c). + * po/POTFILES: Add normal/main.c. + +2009-12-19 Carles Pina i Estany car...@pina.cat + * normal/menu_text.c (STANDARD_MARGIN): New macro. (print_message_indented): Add `margin_left' and `margin_right' parameters. === modified file 'include/grub/normal.h' --- include/grub/normal.h 2009-08-24 23:55:06 + +++ include/grub/normal.h 2009-12-19 01:21:13 + @@ -73,6 +73,12 @@ void grub_parse_color_name_pair (grub_ui /* Defined in `menu_text.c'. */ void grub_wait_after_message (void); +int utf8_to_ucs4 (const char *msg, grub_uint32_t **unicode_msg, + grub_uint32_t **last_position); +void grub_print_ucs4 (const grub_uint32_t * str, + const grub_uint32_t * last_position); +grub_ssize_t getstringwidth (grub_uint32_t * str, + const grub_uint32_t * last_position); /* Defined in `handler.c'. */ void read_handler_list (void); === modified file 'normal/main.c' --- normal/main.c 2009-12-08 00:08:52 + +++ normal/main.c 2009-12-19 01:36:39 + @@ -385,22 +385,31 @@ read_config_file (const char *config) void grub_normal_init_page (void) { - grub_uint8_t width, margin; + grub_cls (); + const char *msg = _(GNU GRUB version %s); -#define TITLE (GNU GRUB version PACKAGE_VERSION) + char *msg_formatted = grub_malloc (grub_strlen(msg) + grub_strlen(PACKAGE_VERSION)); - width = grub_getwh () 8; - margin = (width - (sizeof(TITLE) + 7)) / 2; + grub_sprintf (msg_formatted, msg, PACKAGE_VERSION); - grub_cls (); - grub_putchar ('\n'); + grub_uint32_t *unicode_msg; + grub_uint32_t *last_position; + + int msg_len; - while (margin--) -grub_putchar (' '); + msg_len = utf8_to_ucs4 (msg_formatted, unicode_msg, last_position); + + if (msg_len 0) +{ + return; +} - grub_printf (%s\n\n, TITLE); + int posx = getstringwidth (unicode_msg, last_position); + posx = (GRUB_TERM_WIDTH - posx) / 2; + grub_gotoxy (posx, 1); -#undef TITLE + grub_print_ucs4 (unicode_msg, last_position); + grub_printf(\n\n); } static int reader_nested; === modified file 'normal/menu_text.c' --- normal/menu_text.c 2009-12-19 00:05:41 + +++ normal/menu_text.c 2009-12-19 01:20:58 + @@ -55,7 +55,7 @@ print_spaces (int number_spaces) grub_putchar (' '); } -static void +void grub_print_ucs4 (const grub_uint32_t * str, const grub_uint32_t * last_position) { @@ -66,7 +66,34 @@ grub_print_ucs4 (const grub_uint32_t * s } } -static grub_ssize_t +int +utf8_to_ucs4 (const char *msg, grub_uint32_t **unicode_msg, + grub_uint32_t **last_position) +{ + grub_ssize_t msg_len = grub_strlen (msg); + + *unicode_msg = grub_malloc (grub_strlen (msg) * sizeof (grub_uint32_t)); + + if (!*unicode_msg) +{ + grub_printf (utf8_to_ucs4 ERROR1: %s, msg); + return -1; +} + + msg_len = grub_utf8_to_ucs4 (*unicode_msg, msg_len, + (grub_uint8_t *) msg, -1, 0); + + *last_position = *unicode_msg + msg_len; + + if (msg_len 0) +{ + grub_printf (utf8_to_ucs4 ERROR2: %s, msg); + grub_free (*unicode_msg); +} + return msg_len; +} + +grub_ssize_t getstringwidth (grub_uint32_t * str, const grub_uint32_t * last_position) { grub_ssize_t width = 0; @@ -87,29 +114,17 @@ print_message_indented (const char *msg, (margin_left + margin_right); grub_uint32_t *unicode_msg; + grub_uint32_t *last_position; - grub_ssize_t msg_len = grub_strlen (msg); - - unicode_msg = grub_malloc (msg_len * sizeof (*unicode_msg)); + int msg_len; - msg_len = grub_utf8_to_ucs4 (unicode_msg, msg_len, - (grub_uint8_t *) msg, -1, 0); - - if (!unicode_msg) -{ - grub_printf (print_message_indented ERROR1: %s, msg); - return; -} + msg_len = utf8_to_ucs4 (msg, unicode_msg, last_position); if (msg_len 0) { - grub_printf (print_message_indented ERROR2: %s, msg); - grub_free (unicode_msg); return; } - const grub_uint32_t *last_position = unicode_msg + msg_len; - grub_uint32_t *current_position = unicode_msg; grub_uint32_t *next_new_line = unicode_msg; === modified file 'po/POTFILES' --- po/POTFILES 2009-12-05 11:25:07 + +++ po/POTFILES 2009-12-19 00:32:03 + @@ -11,5 +11,6 @@ util
Re: gettext: version string in normal/main.c
Hi, On Dec/19/2009, Carles Pina i Estany wrote: Something to improve before committing? New patch with a missing grub_free. -- Carles Pina i Estany http://pinux.info === modified file 'ChangeLog' --- ChangeLog 2009-12-19 00:05:41 + +++ ChangeLog 2009-12-19 01:27:34 + @@ -1,5 +1,18 @@ 2009-12-19 Carles Pina i Estany car...@pina.cat + * include/grub/normal.h (utf8_to_ucs4): New declaration. + (grub_print_ucs4): Likewise. + (getstringwidth): Likewise. + * normal/main.c (grub_normal_init_page): Gettextize version string. + * normal/menu_text.c (utf8_to_ucs4): New declaration. + (getstringwidth): Remove `static' qualifier (now used in + normal/main.c). Use `utf8_to_ucs4'. + (grub_print_ucs4): Remove `static' qualifer (now used in + normal/main.c). + * po/POTFILES: Add normal/main.c. + +2009-12-19 Carles Pina i Estany car...@pina.cat + * normal/menu_text.c (STANDARD_MARGIN): New macro. (print_message_indented): Add `margin_left' and `margin_right' parameters. === modified file 'include/grub/normal.h' --- include/grub/normal.h 2009-08-24 23:55:06 + +++ include/grub/normal.h 2009-12-19 01:21:13 + @@ -73,6 +73,12 @@ void grub_parse_color_name_pair (grub_ui /* Defined in `menu_text.c'. */ void grub_wait_after_message (void); +int utf8_to_ucs4 (const char *msg, grub_uint32_t **unicode_msg, + grub_uint32_t **last_position); +void grub_print_ucs4 (const grub_uint32_t * str, + const grub_uint32_t * last_position); +grub_ssize_t getstringwidth (grub_uint32_t * str, + const grub_uint32_t * last_position); /* Defined in `handler.c'. */ void read_handler_list (void); === modified file 'normal/main.c' --- normal/main.c 2009-12-08 00:08:52 + +++ normal/main.c 2009-12-19 01:54:42 + @@ -385,22 +385,32 @@ read_config_file (const char *config) void grub_normal_init_page (void) { - grub_uint8_t width, margin; - -#define TITLE (GNU GRUB version PACKAGE_VERSION) + grub_cls (); + const char *msg = _(GNU GRUB version %s); - width = grub_getwh () 8; - margin = (width - (sizeof(TITLE) + 7)) / 2; + char *msg_formatted = grub_malloc (grub_strlen(msg) + grub_strlen(PACKAGE_VERSION)); - grub_cls (); - grub_putchar ('\n'); + grub_sprintf (msg_formatted, msg, PACKAGE_VERSION); - while (margin--) -grub_putchar (' '); + grub_uint32_t *unicode_msg; + grub_uint32_t *last_position; + + int msg_len; - grub_printf (%s\n\n, TITLE); + msg_len = utf8_to_ucs4 (msg_formatted, unicode_msg, last_position); + + if (msg_len 0) +{ + return; +} -#undef TITLE + int posx = getstringwidth (unicode_msg, last_position); + posx = (GRUB_TERM_WIDTH - posx) / 2; + grub_gotoxy (posx, 1); + + grub_print_ucs4 (unicode_msg, last_position); + grub_printf(\n\n); + grub_free (unicode_msg); } static int reader_nested; === modified file 'normal/menu_text.c' --- normal/menu_text.c 2009-12-19 00:05:41 + +++ normal/menu_text.c 2009-12-19 01:20:58 + @@ -55,7 +55,7 @@ print_spaces (int number_spaces) grub_putchar (' '); } -static void +void grub_print_ucs4 (const grub_uint32_t * str, const grub_uint32_t * last_position) { @@ -66,7 +66,34 @@ grub_print_ucs4 (const grub_uint32_t * s } } -static grub_ssize_t +int +utf8_to_ucs4 (const char *msg, grub_uint32_t **unicode_msg, + grub_uint32_t **last_position) +{ + grub_ssize_t msg_len = grub_strlen (msg); + + *unicode_msg = grub_malloc (grub_strlen (msg) * sizeof (grub_uint32_t)); + + if (!*unicode_msg) +{ + grub_printf (utf8_to_ucs4 ERROR1: %s, msg); + return -1; +} + + msg_len = grub_utf8_to_ucs4 (*unicode_msg, msg_len, + (grub_uint8_t *) msg, -1, 0); + + *last_position = *unicode_msg + msg_len; + + if (msg_len 0) +{ + grub_printf (utf8_to_ucs4 ERROR2: %s, msg); + grub_free (*unicode_msg); +} + return msg_len; +} + +grub_ssize_t getstringwidth (grub_uint32_t * str, const grub_uint32_t * last_position) { grub_ssize_t width = 0; @@ -87,29 +114,17 @@ print_message_indented (const char *msg, (margin_left + margin_right); grub_uint32_t *unicode_msg; + grub_uint32_t *last_position; - grub_ssize_t msg_len = grub_strlen (msg); - - unicode_msg = grub_malloc (msg_len * sizeof (*unicode_msg)); + int msg_len; - msg_len = grub_utf8_to_ucs4 (unicode_msg, msg_len, - (grub_uint8_t *) msg, -1, 0); - - if (!unicode_msg) -{ - grub_printf (print_message_indented ERROR1: %s, msg); - return; -} + msg_len = utf8_to_ucs4 (msg, unicode_msg, last_position); if (msg_len 0) { - grub_printf (print_message_indented ERROR2: %s, msg); - grub_free (unicode_msg); return; } - const grub_uint32_t *last_position = unicode_msg + msg_len; - grub_uint32_t *current_position = unicode_msg; grub_uint32_t *next_new_line = unicode_msg; === modified file 'po/POTFILES' --- po/POTFILES 2009-12-05 11:25:07 + +++ po/POTFILES 2009-12
Re: Unittests
Hi, On Dec/16/2009, BVK Chaitanya wrote: On Tue, Dec 15, 2009 at 5:18 AM, Carles Pina i Estany car...@pina.cat wrote: Writing a unittest for gettext it's very easy: it just needs a couple of .mo and a script executing gettext string and checking that the result is string translated. Will get more interesting when ngettext will come too :-) when I said it's very easy I was thinking more like you explain to me how the unittest infrastructure works and I write the test more than the other way. But no problem at all if you want to write it! I don't have much knowledge about how gettext works, but I tried to add unit test today (in my local branch) and I couldn't get it working :-( Below is what I did, with some questions: 1. I downloaded zh_CN.po from translationproject.org and placed it in $(srcdir)/po/ directory. ok! 2. I tried to build grub.pot, but build failed. ops... Build rule for grub.pot assumes builddir == srcdir, which is not true in my case. Also, it looks like that command is trying to create grub.po in srcdir instead of builddir; is it normal? if we need grub.pot in srcdir, can we move this step into autogen.sh? I'm not familiar with this part, Robert prepared the building system. Of course I can take a look next days or you can propose a patch. 3. After fixing the grub.pot rule, I was able to get .mo files in $(builddir)/po/ 4. Now I wanted to see if gettext could find the translations without doing a make install, as below in $(builddir) $ LANG=zh_CN TEXTDOMAINDIR=$(pwd) gettext grub the core image is too small It displayed only english version, even though zh_CN translation is available :-( Since the directory structure in /usr/share/locale is different from $(builddir), I did make install and tried the gettext command without setting TEXTDOMAINDIR, but still no success :-( What is wrong? Can you provide any pointers? This is not what I wanted to test using the unittest, but I can show a shell script that I did last june testing for these things. car...@pinux:~/grub2/oldgrub/grubprova$ cat test.sh #!/bin/bash export TEXTDOMAIN=testscript export TEXTDOMAINDIR=./locale echo $(gettext hello world) And then: car...@pinux:~/grub2/oldgrub/grubprova$ find . ./locale ./locale/ca ./locale/ca/LC_MESSAGES ./locale/ca/LC_MESSAGES/testscript.mo ./locale/ca...@euro.po ./locale/test.pot ./test.sh car...@pinux:~/grub2/oldgrub/grubprova$ and it works: car...@pinux:~/grub2/oldgrub/grubprova$ ./test.sh hola món car...@pinux:~/grub2/oldgrub/grubprova$ I'm not expert in this area, but $TEXTDOMAINDIR in my case is pointing to locale directory that needs to have the above hierarchy. Plus I think that you need to setup TEXTDOMAINDIR even if the files are correctly places in /usr/share/locale. But what I was thinking to test with the unittest is the gettext.mod, not outside. I could do semi-manually doing: a) Different .mo files with some strings (inside /boot/grub/locale/[.mo files]) b) A Grub2 disk image with the script to check the gettext module. Mainly would do (I'll write in pseudo-Bash, would be in Grub script): --- set lang=ca TESTFAILED=false if [ $(gettext hello world) -ne hola món ] then echo Test failed 01! TESTFAILED=true fi if [ ... ] then echo Test failed 02! TESTFAILED=true fi set lang=es if [ ... ] then fi if [ $TESTFAILED -eq true ] then echo TESTS FAILEDS fi --- So when I do changes in gettext module (like optimizse something, add support for plurals, etc. etc.) I would be sure that everything is all right. Was you thinking something like this? Thanks, -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Unittests
Hello, I remember that BVK was interested to add some unit tests in Grub2. Soon, when gettext will be a bit more far I' could write a unit test for gettext module (habit from work :-) -actually I wanted to do even if I don't publish it). Writing a unittest for gettext it's very easy: it just needs a couple of .mo and a script executing gettext string and checking that the result is string translated. Will get more interesting when ngettext will come too :-) So, BVK, once you have the infrastructure if you ping me gettext could be your guinea pig. Cheers, -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: var=foo should be valid?
Hi, On Dec/12/2009, Carles Pina i Estany wrote: We should fix it. We have three options (maintaining the current behaviour for the user): a) simple_patch (just swapping that two lines) After talking with Robert last night and for the time being I've committed the simple one (r1933) to fix the current bug. -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
gettext: print_timeout
Hello, Find attached a patch about print_timeout. Until now print_timeout had some problems with multi-byte / multi-width characters. Now it's fixed, printing all sentence every time as commented in the IRC. I would like to comment two things: + char *msg_formatted = grub_malloc (sizeof (char) * +(grub_strlen (msg) + 1 + 6)); +/* 5: max string length that `timeout' can have. */ timeout is a int, so the maximum string length that can do is -32768 (makes, no sense, I know). I could calculate the length of the string of the int in base 10 dividing by 10 multiple times but I think that allocating space for 6 position is more than enough, actually grub_strlen already allocates 2 sizeof (char) (because %d). I mean, I can add code to save some bytes in memory. Any better and simpler way? Other thing to clarify: + print_spaces (GRUB_TERM_WIDTH - strwidth - 3); The line is printing spaces from the end of the string until the end of the line (GRUB_TERM_WIDTH). I'm not assuming that the new string with the new timeout is one char shorter like it happens in English because the plurals in some languages can break it. If ok I would commit. -- Carles Pina i Estany http://pinux.info === modified file 'ChangeLog' --- ChangeLog 2009-12-12 00:43:32 + +++ ChangeLog 2009-12-13 00:44:09 + @@ -1,3 +1,10 @@ +2009-12-13 Carles Pina i Estany car...@pina.cat + + * normal/menu_text.c (utf8_to_ucs4): New definition. + (print_message_indented): Use `utf8_to_ucs'. + (print_timeout): Prints the whole string so avoid problems with + multi-byte and multi-width characters. + 2009-12-12 Robert Millan r...@aybabtu.com * gendistlist.sh (EXTRA_DISTFILES): Add `genvideolist.sh'. === modified file 'normal/menu_text.c' --- normal/menu_text.c 2009-12-08 00:08:52 + +++ normal/menu_text.c 2009-12-13 01:26:09 + @@ -77,35 +77,50 @@ getstringwidth (grub_uint32_t * str, con return width; } +static int +utf8_to_ucs4 (const char *msg, grub_uint32_t **unicode_msg, + grub_uint32_t **last_position) +{ + grub_ssize_t msg_len = grub_strlen (msg); + + *unicode_msg = grub_malloc (grub_strlen (msg) * sizeof (grub_uint32_t)); + + if (!*unicode_msg) +{ + grub_printf (utf8_to_ucs4 ERROR1: %s, msg); + return -1; +} + + msg_len = grub_utf8_to_ucs4 (*unicode_msg, msg_len, + (grub_uint8_t *) msg, -1, 0); + + *last_position = *unicode_msg + msg_len; + + if (msg_len 0) +{ + grub_printf (utf8_to_ucs4 ERROR2: %s, msg); + grub_free (*unicode_msg); +} + return msg_len; +} + static void print_message_indented (const char *msg) { const int line_len = GRUB_TERM_WIDTH - grub_getcharwidth ('m') * 15; grub_uint32_t *unicode_msg; + grub_uint32_t *last_position; - grub_ssize_t msg_len = grub_strlen (msg); - - unicode_msg = grub_malloc (msg_len * sizeof (*unicode_msg)); + int msg_len; - msg_len = grub_utf8_to_ucs4 (unicode_msg, msg_len, - (grub_uint8_t *) msg, -1, 0); - - if (!unicode_msg) -{ - grub_printf (print_message_indented ERROR1: %s, msg); - return; -} + msg_len = utf8_to_ucs4 (msg, unicode_msg, last_position); if (msg_len 0) { - grub_printf (print_message_indented ERROR2: %s, msg); - grub_free (unicode_msg); return; } - const grub_uint32_t *last_position = unicode_msg + msg_len; - grub_uint32_t *current_position = unicode_msg; grub_uint32_t *next_new_line = unicode_msg; @@ -368,22 +383,39 @@ get_entry_number (const char *name) } static void -print_timeout (int timeout, int offset, int second_stage) +print_timeout (int timeout, int offset, + int second_stage __attribute__ ((unused))) { const char *msg = _(The highlighted entry will be booted automatically in %ds.); - const int msg_localized_len = grub_strlen (msg); - const int number_spaces = GRUB_TERM_WIDTH - msg_localized_len - 3; - char *msg_end = grub_strchr (msg, '%'); + char *msg_formatted = grub_malloc (sizeof (char) * +(grub_strlen (msg) + 1 + 6)); +/* 5: max string length that `timeout' can have. */ + + grub_sprintf (msg_formatted, msg, timeout); + + grub_uint32_t *unicode_msg; + grub_uint32_t *last_position; + + int msg_len = utf8_to_ucs4 (msg_formatted, unicode_msg, last_position); + if (msg_len 0) +{ + return; +} - grub_gotoxy (second_stage ? (msg_end - msg + 3) : 3, GRUB_TERM_HEIGHT - 3); - grub_printf (second_stage ? msg_end : msg, timeout); - print_spaces (second_stage ? number_spaces : 0); + grub_gotoxy (3, GRUB_TERM_HEIGHT - 3); + grub_print_ucs4 (unicode_msg, last_position); + + int strwidth = getstringwidth (unicode_msg, last_position); + + print_spaces (GRUB_TERM_WIDTH - strwidth - 3); + + grub_free(unicode_msg); grub_gotoxy (GRUB_TERM_CURSOR_X, GRUB_TERM_FIRST_ENTRY_Y + offset); grub_refresh (); -}; +} /* Show the menu
Re: [PATCH] Backup old boot sectors before installation
Hi, On Dec/11/2009, Felix Zielcke wrote: Am Freitag, den 11.12.2009, 17:26 +0800 schrieb Zhu Yi: Add a feature to backup the old boot sectors before overwritting them with grub2 boot and core images. Users can later recover the previous boot sectors with grub-install --recover option. P.S. I found this might be a useful feature after I overwrote my second PGP encrypted hard disk (Windows XP installed) boot sectors by grub2 by mistake. Signed-off-by: Zhu Yi yi@intel.com Someone already made a patch for this inside grub-setup See here and also for the discussion of it: http://lists.gnu.org/archive/html/grub-devel/2009-09/msg00242.html I like the idea, and I think that as Colin pointed it out it can be useful. I haven't watched to any of the implementations. -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
gettext: print_timeout
Hi, print_timeout is not working fine when the translated string contains multi-byte characters, because it's locating where to write the seconds when second_stage == 1 (so the seconds when second_stage == 1 are miss-placed). Tomorrow evening or Sunday I will fix it. -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: var=foo should be valid?
Hi, On Dec/04/2009, Carles Pina i Estany wrote: Hi, On Dec/04/2009, Robert Millan wrote: On Sun, Nov 29, 2009 at 06:39:36PM +, Carles Pina i Estany wrote: (first one has a bug but very easy to fix, even thought I would maybe refactor this code to implement in other way) Can you give more details about this bug and the refactor that would be needed? Find attached the simple patch (without refactoring) (it resets grub_errno _before_ grub_env_set, because grub_env_set calls the hooked functions). We should fix it. We have three options (maintaining the current behaviour for the user): a) simple_patch (just swapping that two lines) b) refactoring patch (calls the same function with set as command and the passed command as arguments, etc. should be possible but I haven't implemented) c) play with the grammatic of the language instead of fallback in the execution of the each line. Not sure how feasible it is since I haven't look into it. a) would be the patch that I attached, b) I would do it in a couple of days, hopefully. c) I would not do it for quite long time and I think that some other people could fix it. If we go for c) maybe we could commit a) as a temporary fix waiting for some other changes in teh grammar. Even, for c) would be nice to have the unit tests to see if we break other things. Thanks, -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: Build failures on Ubuntu due to gettext
Hi, On Dec/10/2009, Robert Millan wrote: On Tue, Dec 08, 2009 at 12:10:34AM +, Colin Watson wrote: Even if we're only discussing a change in five places, I assume we're going to find this situation in lots of calls throurough GRUB code. If this is so, it really calls for a solution that doesn't make GCC generate two memory references and pass two arguments. So first of all, how many times are we going to find similar calls that very rush numbers, based on my non-commited pending to improve patch to change commands/*: car...@pinux:~/grub2/grub/po$ grep -A 3 \#\: commands\/ grub.pot | grep ^msgid | grep -c -v % 86 need to be adjusted in some way? If we're going to find many of them (as I expect), I think this warrants adding a new function (which, btw, will also make GRUB slightly faster). Plus about 10 in normal/* (aprox, 5 that Colin did and some more in another pending patch I guess) I haven't looked in other code yet. I think that Vladimir proposed to do it in a macro now and then properly count and implement as a function or not later. From: Vladimir Date: Tue, 08 Dec 2009 01:15:30 +0100 Then it's not worth it. But again we haven't gettext'ized whole grub2 yet to know for sure. Perhaps a macro so we can change it later if necessary? So, for about 86 in commands/* and probably some more in normal/*: function now? Now a macro and then we review? Colin: for me you can commit your patch some way or another so you could compile in Ubuntu and I can commit soon more things. Thanks, -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: Build failures on Ubuntu due to gettext
Hi Vladimir, Colin, On Dec/08/2009, Vladimir '??-coder/phcoder' Serbinenko wrote: My patch made the following transformation: - grub_printf (_(literal string)); + grub_printf (%s, _(literal string)); This was only necessary in five places, so I doubt that a function is worth it. Then it's not worth it. But again we haven't gettext'ized whole grub2 yet to know for sure. Perhaps a macro so we can change it later if necessary? Vladimir, Colin: see the attached patch with the Colin changes but macrofied. Should compile fine in Ubuntu, but I have not tried. Are we happy with grub_put_ function name? Colin: could you apply this patch or similar? I don't want to push more gettext strings before setting up the basic infrastructure to avoid working twice. Thanks, -- Carles Pina i Estany http://pinux.info === modified file 'include/grub/misc.h' --- include/grub/misc.h 2009-12-08 00:08:52 + +++ include/grub/misc.h 2009-12-09 23:51:07 + @@ -34,6 +34,8 @@ /* XXX: If grub_memmove is too slow, we must implement grub_memcpy. */ #define grub_memcpy(d,s,n) grub_memmove ((d), (s), (n)) +#define grub_put_(str) grub_printf(%s, (str)) + void *EXPORT_FUNC(grub_memmove) (void *dest, const void *src, grub_size_t n); char *EXPORT_FUNC(grub_strcpy) (char *dest, const char *src); char *EXPORT_FUNC(grub_strncpy) (char *dest, const char *src, int c); === modified file 'normal/menu_entry.c' --- normal/menu_entry.c 2009-12-08 00:08:52 + +++ normal/menu_entry.c 2009-12-09 23:46:36 + @@ -1000,7 +1000,7 @@ run (struct screen *screen) grub_cls (); grub_printf ( ); - grub_printf_ (N_(Booting a command list)); + grub_put_ (N_(Booting a command list)); grub_printf (\n\n); @@ -1182,6 +1182,6 @@ grub_menu_entry_run (grub_menu_entry_t e grub_print_error (); grub_errno = GRUB_ERR_NONE; grub_putchar ('\n'); - grub_printf_ (N_(Press any key to continue...)); + grub_put_ (N_(Press any key to continue...)); (void) grub_getkey (); } === modified file 'normal/menu_text.c' --- normal/menu_text.c 2009-12-08 00:08:52 + +++ normal/menu_text.c 2009-12-09 23:47:04 + @@ -40,7 +40,7 @@ void grub_wait_after_message (void) { grub_putchar ('\n'); - grub_printf_ (N_(Press any key to continue...)); + grub_put_ (N_(Press any key to continue...)); (void) grub_getkey (); grub_putchar ('\n'); } @@ -206,7 +206,7 @@ entry is highlighted.); if (nested) { grub_printf (\n); - grub_printf_ (N_(ESC to return previous menu.)); + grub_put_ (N_(ESC to return previous menu.)); } } } @@ -655,7 +655,7 @@ notify_execution_failure (void *userdata grub_errno = GRUB_ERR_NONE; } grub_printf (\n ); - grub_printf_ (N_(Failed to boot default entries.\n)); + grub_put_ (N_(Failed to boot default entries.\n)); grub_wait_after_message (); } ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: Build failures on Ubuntu due to gettext
Hi, As Vladimir spotted: On Dec/09/2009, Carles Pina i Estany wrote: This...: +#define grub_put_(str) grub_printf(%s, (str)) should be: #define grub_put_(str) grub_printf(N_ (%s), (str)) If you Colin commit it don't propagate my mistake. -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: Build failures on Ubuntu due to gettext
Hi, On Dec/10/2009, Carles Pina i Estany wrote: As Richard commented (thanks): #define grub_put_(str) grub_printf(N_ (%s), (str)) #define grub_put_(str) grub_printf(%s, N (str)) I should not be sending patches when too tired / without properly testing with the .po that I've just deleted doing some other tests :-) Now should be fine and after it's committed next gettext patches will use it when needed. Cheers, -- 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: commands/*
Hi, On Dec/07/2009, Carles Pina i Estany wrote: And then implement grub_printf_: - int grub_printf_ (const char *fmt, ...) { va_list ap; int ret; va_start (ap, fmt); ret = grub_vprintf (_(fmt), ap); actually I would better call grub_printf here instead of grub_vprintf -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: Build failures on Ubuntu due to gettext
Hello, On Dec/07/2009, Colin Watson wrote: Ubuntu's GCC enables -Wformat-security by default. This causes GCC to (IMO rightly!) complain about constructs such as this: grub_printf (_(foo)); I see... (actually some weeks ago I thought about gettext security implications, and I thought that if someone can change the .mo files there is some bigger problem for the user... but I understand the point) ... because it's all too easy for a translator to (usually accidentally) insert % sequences which would cause printf to behave (side and non-relevant note: if the translator wants to do some damage on purpose he doesn't need to play with %s and %d, it's as easy as changing strings from Press C to Cancel and D to delete to something like (in another language) Press D to Cancel and C to delete) incorrectly. This should instead be: grub_printf (%s, _(foo)); I like the general idea but I'm not 100% convinced of the implementation: a) It's a bit of false security because it's not fixing the case of file normal/menu_text.c, line 191 (search the string Use the %C and %C keys to) or menu_text.c line 374 (search for The highlighted entry) (I agree that it's better than before... but not very solid) b) How would you translate and handle: grub_printf (_(Hello %s), name); The translator really needs %s because in other languages can be %s hello (not the best example but maybe you get the point) c) I'm thinking to implement grub_printf_ (str). I will send a patch later to see if everybody likes. Then the call for simple strings would be: grub_printf_ (%s, N_(Hello)); Not much different from: grub_printf_ (N_(Hello)); But it's getting hard to print a string :-) d) (important, even if it's the last one): How it prevents mistakes from the current msgfmt checks? For example, and using the option -c in msgfmt: #: normal/misc.c:67 #, c-format msgid test %s t msgstr test %d test2 /usr/bin/msgfmt -c --statistics -o po/ca.mo po/ca.po po/ca.po:1183: format specifications in 'msgid' and 'msgstr' for argument 1 are not the same /usr/bin/msgfmt: found 1 fatal error 26 translated messages, 213 untranslated messages. Using any different number of %X from msgid and msgstr ishalting msgfmt (so, if msgid contains 1 %s and 2 %d, msgstr has to contain the same) We are talking from _( ), I see that -Wformat-security is for string came from untrusted input and contains when .mo are trusted. Are they? How are other projectes implementing it? Specially the dynamic strings. Patch follows. I can't help thinking that this would be easier with a grub_puts, but perhaps that isn't worth it given the relatively small number of occurrences here? We could replace grub_puts with grub_printf... or some other idea. Also, should the line in notify_execution_failure instead be: - grub_printf (_(Failed to boot default entries.\n)); + grub_printf (%s\n, _(Failed to boot default entries.)); ... to get rid of the unsightly \n in this translated string? I really like that this fix the \n discussion that we had :-) I like the idea and I understand that it's easy to make mistakes translating strings. Actually I'm surprised that msgfmt is not giving any warning if the -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
gettext: grub_printf_ and N_
Hi, Attached a patch that makes a new function (grub_printf_) which one calls _( ) for the format argument. Also adapts the current translations but not the pending patch. Can someone take a look? If the grub_printf_ approach is used then this should be committed. Conflicts with Colin Watson idea because in the other idea gettext has to be called in grub_printf level and not inside, as far as I can think now :-) -- Carles Pina i Estany http://pinux.info === modified file 'ChangeLog' --- ChangeLog 2009-12-07 16:46:24 + +++ ChangeLog 2009-12-07 21:08:05 + @@ -1,3 +1,17 @@ +2009-12-07 Carles Pina i Estany car...@pina.cat + + * include/grub/misc.h (grub_printf_): New declaration. + * kern/misc.c (grub_printf_): New definition. + * normal/main.c (grub_normal_reader_init): Use `grub_printf_' and `N_' + instead of `grub_printf' and `_'. + * normal/menu_entry.c (store_completion): Likewise. + (run): Likewise. + (grub_menu_entry_run): Likewise. + * normal/menu_text.c (grub_wait_after_message): Likewise. + (notify_booting): Likewise. + (notify_fallback): Likewise. + (notify_execution_failure): Likewise. + 2009-12-07 Colin Watson cjwat...@ubuntu.com * configure.ac: Check for vasprintf. === modified file 'include/grub/misc.h' --- include/grub/misc.h 2009-12-03 23:07:29 + +++ include/grub/misc.h 2009-12-07 21:00:46 + @@ -171,6 +171,7 @@ char *EXPORT_FUNC(grub_strndup) (const c void *EXPORT_FUNC(grub_memset) (void *s, int c, grub_size_t n); grub_size_t EXPORT_FUNC(grub_strlen) (const char *s); int EXPORT_FUNC(grub_printf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); +int EXPORT_FUNC(grub_printf_) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); void EXPORT_FUNC(grub_real_dprintf) (const char *file, const int line, const char *condition, === modified file 'kern/misc.c' --- kern/misc.c 2009-11-24 21:42:14 + +++ kern/misc.c 2009-12-07 20:59:09 + @@ -126,6 +126,19 @@ grub_printf (const char *fmt, ...) return ret; } +int +grub_printf_ (const char *fmt, ...) +{ + va_list ap; + int ret; + + va_start (ap, fmt); + ret = grub_printf (_(fmt), ap); + va_end (ap); + + return ret; +} + #if defined (APPLE_CC) ! defined (GRUB_UTIL) int grub_err_printf (const char *fmt, ...) === modified file 'normal/main.c' --- normal/main.c 2009-11-25 03:48:33 + +++ normal/main.c 2009-12-07 21:02:14 + @@ -509,7 +509,7 @@ grub_normal_reader_init (void) grub_normal_init_page (); grub_setcursor (1); - grub_printf (_(\ + grub_printf_ (N_(\ [ Minimal BASH-like line editing is supported. For the first word, TAB\n\ lists possible command completions. Anywhere else TAB lists possible\n\ device/file completions.%s ]\n\n), === modified file 'normal/menu_entry.c' --- normal/menu_entry.c 2009-12-05 11:25:07 + +++ normal/menu_entry.c 2009-12-07 21:02:48 + @@ -837,7 +837,7 @@ store_completion (const char *item, grub grub_gotoxy (0, GRUB_TERM_HEIGHT - 3); grub_printf ( ); - grub_printf (_(Possible %s are:), what); + grub_printf_ (N_(Possible %s are:), what); grub_printf (\n); } @@ -1000,7 +1000,7 @@ run (struct screen *screen) grub_cls (); grub_printf ( ); - grub_printf (_(Booting a command list)); + grub_printf_ (N_(Booting a command list)); grub_printf (\n\n); @@ -1182,6 +1182,6 @@ grub_menu_entry_run (grub_menu_entry_t e grub_print_error (); grub_errno = GRUB_ERR_NONE; grub_putchar ('\n'); - grub_printf (_(Press any key to continue...)); + grub_printf_ (N_(Press any key to continue...)); (void) grub_getkey (); } === modified file 'normal/menu_text.c' --- normal/menu_text.c 2009-12-05 11:25:07 + +++ normal/menu_text.c 2009-12-07 21:01:41 + @@ -40,7 +40,7 @@ void grub_wait_after_message (void) { grub_putchar ('\n'); - grub_printf (_(Press any key to continue...)); + grub_printf_ (N_(Press any key to continue...)); (void) grub_getkey (); grub_putchar ('\n'); } @@ -206,7 +206,7 @@ entry is highlighted.); if (nested) { grub_printf (\n); - grub_printf (_(ESC to return previous menu.)); + grub_printf_ (N_(ESC to return previous menu.)); } } } @@ -627,7 +627,7 @@ notify_booting (grub_menu_entry_t entry, void *userdata __attribute__((unused))) { grub_printf ( ); - grub_printf (_(Booting \'%s\'), entry-title); + grub_printf_ (N_(Booting \'%s\'), entry-title); grub_printf (\n\n); } @@ -639,7 +639,7 @@ notify_fallback (grub_menu_entry_t entry void *userdata __attribute__((unused))) { grub_printf (\n ); - grub_printf (_(Falling back to \'%s\'), entry-title); + grub_printf_ (N_(Falling back to \'%s\'), entry-title); grub_printf (\n\n); grub_millisleep (DEFAULT_ENTRY_ERROR_DELAY_MS); } @@ -655,7 +655,7 @@ notify_execution_failure (void *userdata grub_errno
Re: gettext: normal/*
Hi, On Dec/07/2009, Jordi Mallach wrote: On Sun, Dec 06, 2009 at 12:28:11AM +, Carles Pina i Estany wrote: Is it fine to have a translatable string ended with a space? I think that it's fine (same case than \n, even thought in this case msgfmt is not warning). [...] IME, if it's not difficult to get rid of it, it better to do it for safety, because it's a common translator mistake. I will remove the spaces. Only in one place is not straight but it's not difficult. Thanks, -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: Build failures on Ubuntu due to gettext
Hi, On Dec/07/2009, Colin Watson wrote: On Mon, Dec 07, 2009 at 08:14:08PM +, Carles Pina i Estany wrote: a) It's a bit of false security because it's not fixing the case of file normal/menu_text.c, line 191 (search the string Use the %C and %C keys to) or menu_text.c line 374 (search for The highlighted entry) (I agree that it's better than before... but not very solid) Forget security, in this case; let's just think of it as a way to avoid Ok, I'll forget about security (even when the name is not helping to forget about security :-) ) b) How would you translate and handle: grub_printf (_(Hello %s), name); -Wformat-security doesn't interfere with that. As its documentation says: At present, this warns about calls to `printf' and `scanf' functions where the format string is not a string literal and there are no format arguments, as in `printf (foo);'. I see now (not before) Using any different number of %X from msgid and msgstr ishalting msgfmt (so, if msgid contains 1 %s and 2 %d, msgstr has to contain the same) That only works for strings with the c-format attribute, which xgettext only applies (and should only apply) to msgids that contain %. It helps for the string you mentioned earlier with %C in the msgid, right. Actually I was expecting that all strings in a C file would has c-format, but it's not the case: #: normal/menu_entry.c:840 #, c-format msgid Possible %s are: #: normal/menu_entry.c:1003 msgid Booting a command list And confirmed: if the translator adds %C in the second string (Booting a command list) msgfmt -c is not complaining. So I would apply your patch, after understanding that it's only for strings that doesn't have any %C (and in my opinion xgettext could add the c-format if it's in a C file, but we will not discuss it here now :-) , I guess that in some cases would not be correct) Your patch conflicts with my one (Subject: gettext: grub_printf_ and N_) but it's not a big problem. If you commit before I would adapt my one, else I would adapt your one. -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: Build failures on Ubuntu due to gettext
Hi, On Dec/07/2009, Vladimir '??-coder/phcoder' Serbinenko wrote: Colin Watson wrote: Ubuntu's GCC enables -Wformat-security by default. This causes GCC to (IMO rightly!) complain about constructs such as this: grub_printf (_(foo)); ... because it's all too easy for a translator to (usually accidentally) insert % sequences which would cause printf to behave incorrectly. This should instead be: grub_printf (%s, _(foo)); Patch follows. I can't help thinking that this would be easier with a grub_puts, but perhaps that isn't worth it given the relatively small number of occurrences here? Also, should the line in notify_execution_failure instead be: - grub_printf (_(Failed to boot default entries.\n)); + grub_printf (%s\n, _(Failed to boot default entries.)); ... to get rid of the unsightly \n in this translated string? This warning is simply wrong in this context. And silencing it is against gettext manual. Read http://www.gnu.org/software/hello/manual/gettext/Preparing-Strings.html http://www.gnu.org/software/hello/manual/gettext/c_002dformat-Flag.html#c_002dformat-Flag other solution that I like even more (but I have a problem to implement): use --flag=_:1:pass-c-format . So all strings will be c-format and msgfmt will check the number of parameters (even if the string doesn't have %C, will be c-format and msgfmt should complain if msgstr has a new %C) -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: Build failures on Ubuntu due to gettext
Hi, On Dec/07/2009, Carles Pina i Estany wrote: So I would apply your patch, after understanding that it's only for one more thing Colin. What do you think to not apply your patch and apply the attached patch? It force that the argument 1 of _ and N_ is a c-format (in this way appears in grub.pot). This is, IMO, correct approach. And then msgfmt -c checks the number of arguments. If other projects are not using this approach they could have some reason, like _(File) is a menu label and not a C format string. In this cases, if this happens in Grub it's not making things worse. Using it we should have all checks about the number of arguments and we are not programming warning oriented. If it's a linguism and wide accepted to do in the other way I personally don't have any strong objection. -- Carles Pina i Estany http://pinux.info === modified file 'Makefile.in' --- Makefile.in 2009-11-30 01:25:57 + +++ Makefile.in 2009-12-07 23:28:49 + @@ -477,7 +477,7 @@ genkernsyms.sh: genkernsyms.sh.in config $(SHELL) ./config.status $(srcdir)/po/$(PACKAGE).pot: po/POTFILES po/POTFILES-shell - cd $(srcdir) $(XGETTEXT) --from-code=utf-8 -o $@ -f $ --keyword=_ --keyword=N_ + cd $(srcdir) $(XGETTEXT) --from-code=utf-8 -o $@ -f $ --keyword=_ --keyword=N_ --flag=N_:1:c-format --flag=_:1:c-format cd $(srcdir) $(XGETTEXT) --from-code=utf-8 -o $@ -f po/POTFILES-shell -j --language=Shell $(foreach lang, $(LINGUAS), $(srcdir)/po/$(lang).po): po/$(PACKAGE).pot ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: Build failures on Ubuntu due to gettext
Hi, On Dec/08/2009, Colin Watson wrote: On Mon, Dec 07, 2009 at 10:46:30PM +, Carles Pina i Estany wrote: Your patch conflicts with my one (Subject: gettext: grub_printf_ and N_) but it's not a big problem. If you commit before I would adapt my one, else I would adapt your one. Please go ahead with your patch after due discussion, and I'll adjust mine afterwards. It's too confusing to try to discuss both at the same time. I just pushed my one since I understand that it's all right (using grub_vprintf). And it's complementary with your one. If you push your one (for which one I agree) I will adjust my pending patches to follow the coding sytle. Thanks, -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
gettext: commands/hdparm.c
Hello, commands/hdparm.c has some grub_printf's: grub_printf (Model:\%.40s\\n, le16_to_char (tmp, idw[27], 40)); grub_printf (Firmware: \%.8s\\n, le16_to_char (tmp, idw[23], 8)); grub_printf (Serial: \%.20s\\n, le16_to_char (tmp, idw[10], 20)); To have a proper alignment it needs to code something (dynamic tab). I could change it to: grub_printf (_(Model:\t\%.40s\\n), le16_to_char (tmp, idw[27], 40)); grub_printf (_(Firmware:\t\%.8s\\n), le16_to_char (tmp, idw[23], 8)); grub_printf (_(Serial:\t\%.20s\\n), le16_to_char (tmp, idw[10], 20)); Or just don't translate Model/Firmware/Serial (leave like it's now) Or do the dynamic coding that maybe it's not needed... Thoughts? -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
gettext: commands/*
Hello, I've started to add gettext support in commands/* See the attached patch and ChangeLog. It's not completely exhaustive (hdparm is not in this patch). Comments before committing? Notice the the grub_register_command use N_( ) and then these strings gets registered in commands/help.c when they are gonna to be on the screen. I've tried to translate grub_register_command and the obvious grub_printf. Maybe some more things need to be translated (other strings for example). It will be, but I would like to add gettext support to the 90% of the strings soon so the translators can start to work on it (and finish everything of course). -- Carles Pina i Estany http://pinux.info 2009-12-XX Carles Pina i Estany car...@pina.cat * commands/blocklist.c: Gettextizze. * commands/boot.c: Likewise. * commands/cat.c: Likewise. * commands/cmp.c: Likewise. * commands/configfile.c: Likewise. * commands/crc.c: Likewise. * commands/date.c: Likewise. * commands/efi/fixvideo.c: Likewise. * commands/efi/loadbios.c: Likewise. * commands/gptsync.c: Likewise. * commands/halt.c: Likewise. * commands/handler.c: Likewise. * commands/help.c: Likewise. * commands/i386/pc/play.c: Likewise. * commands/i386/pc/play.c: Likewise. * commands/i386/pc/vbeinfo.c: Likewise. * commands/ieee1275/suspend.c: Likewise. * commands/lsmmap.c: Likewise. * commands/lspci.c: Likewise. * commands/memrw.c: Likewise. * commands/minicmd.c: Likewise. * commands/parttool.c: Likewise. * commands/password.c: Likewise. * commands/read.c: Likewise. * commands/reboot.c: Likewise. * commands/test.c: Likewise. * commands/true.c: Likewise. * commands/usbtest.c: Likewise. * commands/videotest.c: Likewise. * commands/xnu_uuid.c: Likewise. === modified file 'commands/blocklist.c' --- commands/blocklist.c 2009-06-10 21:04:23 + +++ commands/blocklist.c 2009-12-06 16:40:29 + @@ -24,6 +24,7 @@ #include grub/disk.h #include grub/partition.h #include grub/command.h +#include grub/i18n.h static grub_err_t grub_cmd_blocklist (grub_command_t cmd __attribute__ ((unused)), @@ -110,7 +111,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(blocklist) { cmd = grub_register_command (blocklist, grub_cmd_blocklist, - blocklist FILE, Print a block list.); + N_(blocklist FILE), N_(Print a block list.)); } GRUB_MOD_FINI(blocklist) === modified file 'commands/boot.c' --- commands/boot.c 2009-06-10 21:04:23 + +++ commands/boot.c 2009-12-06 16:39:59 + @@ -23,6 +23,7 @@ #include grub/loader.h #include grub/kernel.h #include grub/mm.h +#include grub/i18n.h static grub_err_t (*grub_loader_boot_func) (void); static grub_err_t (*grub_loader_unload_func) (void); @@ -186,7 +187,7 @@ GRUB_MOD_INIT(boot) { cmd_boot = grub_register_command (boot, grub_cmd_boot, - 0, boot an operating system); + 0, N_(boot an operating system)); } GRUB_MOD_FINI(boot) === modified file 'commands/cat.c' --- commands/cat.c 2009-06-10 21:04:23 + +++ commands/cat.c 2009-12-06 16:39:59 + @@ -24,6 +24,7 @@ #include grub/misc.h #include grub/gzio.h #include grub/command.h +#include grub/i18n.h static grub_err_t grub_cmd_cat (grub_command_t cmd __attribute__ ((unused)), @@ -78,7 +79,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(cat) { cmd = grub_register_command_p1 (cat, grub_cmd_cat, - cat FILE, Show the contents of a file.); + N_(cat FILE), N_(Show the contents of a file.)); } GRUB_MOD_FINI(cat) === modified file 'commands/cmp.c' --- commands/cmp.c 2009-06-10 21:04:23 + +++ commands/cmp.c 2009-12-06 17:43:37 + @@ -23,6 +23,7 @@ #include grub/mm.h #include grub/gzio.h #include grub/command.h +#include grub/i18n.h #define BUFFER_SIZE 512 @@ -40,7 +41,7 @@ grub_cmd_cmp (grub_command_t cmd __attri if (argc != 2) return grub_error (GRUB_ERR_BAD_ARGUMENT, two arguments required); - grub_printf (Compare `%s' and `%s':\n, args[0], + grub_printf (_(Compare `%s' and `%s':\n), args[0], args[1]); file1 = grub_gzfile_open (args[0], 1); @@ -49,7 +50,7 @@ grub_cmd_cmp (grub_command_t cmd __attri goto cleanup; if (grub_file_size (file1) != grub_file_size (file2)) -grub_printf (Differ in size: %llu [%s], %llu [%s]\n, +grub_printf (_(Differ in size: %llu [%s], %llu [%s]\n), (unsigned long long) grub_file_size (file1), args[0], (unsigned long long) grub_file_size (file2), args[1]); else @@ -76,7 +77,7 @@ grub_cmd_cmp (grub_command_t cmd __attri { if (buf1[i] != buf2[i]) { - grub_printf (Differ at the offset %llu: 0x%x [%s], 0x%x [%s]\n, + grub_printf (_(Differ at the offset %llu: 0x%x [%s], 0x%x [%s]\n), (unsigned long long) (i + pos), buf1[i], args[0], buf2[i], args[1
Re: gettext: commands/*
Hi, On Dec/06/2009, Carles Pina i Estany wrote: - grub_printf (The files are identical.\n); + grub_printf (_(The files are identical.\n)); Vladimir suggested in IRC that instead of using: grub_printf (grub_gettext (str)) // This is with _() expanded I could use: grub_printf_ (str); To reduce the size in disk. I suggest to implement something like: grub_printf_ (N_(bla bla %s bla), msg); And then implement grub_printf_: - int grub_printf_ (const char *fmt, ...) { va_list ap; int ret; va_start (ap, fmt); ret = grub_vprintf (_(fmt), ap); va_end (ap); return ret; } - AFAIK, xgettext keyword (-k) needs that the keyword wraps the string, in order to extract it to the .pot file, so it's not possible to do a very generic function like: grub_printf_ (bla bla %s bla, msg); xgettext would not extract the string. Maybe Jordi has something to say about this last part. If we want this approach tell me: I would implement it soon and prepare a patch with the implementation, then redo gettext: normal/* patch with this new approach, adapt the old code and finally do the commands/* again and move from here (still some more files and things to do). Thanks, -- Carles Pina i Estany http://pinux.info ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel