From: Carles Pina i Estany Date: Sun, 22 Nov 2009 12:50:46 +0000 (+0000) Subject: This commit is the same than gettext08.patch (see mailing list) X-Git-Tag: 1.98~378^2~13 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e5fb78c684240e2db5e38dac1b93d1c19b142dfe;p=thirdparty%2Fgrub.git This commit is the same than gettext08.patch (see mailing list) --- diff --git a/ChangeLog.gettext b/ChangeLog.gettext index 6bce3f38b..a62869861 100644 --- a/ChangeLog.gettext +++ b/ChangeLog.gettext @@ -1,15 +1,18 @@ YYYY-MM-DD Carles Pina i Estany - * conf/common.rmk: Add grub-gettext_lib target, dependency and - SOURCES, CFLAGS, LDFLAGS - * gettext/gettext.c: New file with gettext implementation - * include/grub/i18n_grub.h: New file with grub_gettext macros - * include/grub/misc.h: Define macro _(char *s). Declare - grub_gettext_dummy and grub_gettext - * kern/misc.c: Define grub_gettext symbol implementation of the - grub_gettext_dummy function - * normal/menu_text.c: Gettextize one message in print_message - * po/POTFILES: Adds normal/menu_text.c - * po/ca.po: Adds the new string - * util/grub.d/00_header.in: defines gettext variables and loads - the module + * conf/common.rmk: Add grub-gettext_lib target and updates + lib_DATA and CLEANFILES. Adds gettext.mod SOURCES, CFLAGS, + LDFLAGS. + * gettext/gettext.c: New file. (Reads mo files). + * include/grub/file.h (grub_file_pread): New prototype. + * include/grub/i18n.h (_): New prototype. + * include/grub/misc.h (grub_gettext_dummy, grub_gettext): New + prototypes. + * kern/misc.c (grub_gettext_dummy): New function. + * menu/menu_text.c: Include . + * menu/menu_text.c (print_timeout): Gettexttize string. + * menu/menu_text.c (print_message): Gettexttize string. + * po/POTFILES: Add `normal/menu_text.c'. + * po/ca.po: Add new translations. + * util/grub.d/00_header.in: Define locale_dir and lang. insmod + gettext module and defines locale_dir and lang in grub.cfg. diff --git a/conf/common.rmk b/conf/common.rmk index a4c3c80e8..be0543d83 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -185,7 +185,7 @@ grub-mkconfig_DATA += util/grub.d/README pkglib_MODULES += fshelp.mod fat.mod ufs1.mod ufs2.mod ext2.mod ntfs.mod \ ntfscomp.mod minix.mod hfs.mod jfs.mod iso9660.mod xfs.mod \ affs.mod sfs.mod hfsplus.mod reiserfs.mod cpio.mod tar.mod \ - udf.mod afs.mod afs_be.mod befs.mod befs_be.mod + udf.mod afs.mod afs_be.mod befs.mod befs_be.mod # For fshelp.mod. fshelp_mod_SOURCES = fs/fshelp.c diff --git a/gettext/gettext.c b/gettext/gettext.c index c488f0e50..799d8a037 100644 --- a/gettext/gettext.c +++ b/gettext/gettext.c @@ -48,12 +48,23 @@ static const char *(*grub_gettext_original) (const char *s); #define MO_MAGIC_NUMBER 0x950412de +static grub_ssize_t +grub_gettext_pread (grub_file_t file, void *buf, grub_size_t len, + grub_off_t offset) +{ + if (grub_file_seek (file, offset) == (grub_off_t) - 1) + { + return -1; + } + return grub_file_read (file, buf, len); +} + static grub_uint32_t grub_gettext_get_info (int offset) { grub_uint32_t value; - grub_file_pread (fd_mo, (char *) &value, 4, offset); + grub_gettext_pread (fd_mo, (char *) &value, 4, offset); value = grub_cpu_to_le32 (value); return value; @@ -63,7 +74,7 @@ static void grub_gettext_getstring_from_offset (grub_uint32_t offset, grub_uint32_t length, char *translation) { - grub_file_pread (fd_mo, translation, length, offset); + grub_gettext_pread (fd_mo, translation, length, offset); translation[length] = '\0'; } @@ -79,10 +90,10 @@ grub_gettext_gettranslation_from_position (int position) internal_position = offsettranslation + position * 8; - grub_file_pread (fd_mo, (char *) &length, 4, internal_position); + grub_gettext_pread (fd_mo, (char *) &length, 4, internal_position); length = grub_cpu_to_le32 (length); - grub_file_pread (fd_mo, (char *) &offset, 4, internal_position + 4); + grub_gettext_pread (fd_mo, (char *) &offset, 4, internal_position + 4); offset = grub_cpu_to_le32 (offset); translation = grub_malloc (length + 1); @@ -102,10 +113,10 @@ grub_gettext_getstring_from_position (int position) internal_position = grub_gettext_offsetoriginal + (position * 8); /* Get the length of the string i. */ - grub_file_pread (fd_mo, (char *) &length, 4, internal_position); + grub_gettext_pread (fd_mo, (char *) &length, 4, internal_position); /* Get the offset of the string i. */ - grub_file_pread (fd_mo, (char *) &offset, 4, internal_position + 4); + grub_gettext_pread (fd_mo, (char *) &offset, 4, internal_position + 4); /* Get the string i. */ original = grub_malloc (length + 1); diff --git a/include/grub/file.h b/include/grub/file.h index 6625e045d..2aacf936f 100644 --- a/include/grub/file.h +++ b/include/grub/file.h @@ -55,8 +55,6 @@ grub_file_t EXPORT_FUNC(grub_file_open) (const char *name); grub_ssize_t EXPORT_FUNC(grub_file_read) (grub_file_t file, void *buf, grub_size_t len); grub_off_t EXPORT_FUNC(grub_file_seek) (grub_file_t file, grub_off_t offset); -grub_ssize_t EXPORT_FUNC(grub_file_pread) (grub_file_t file, void *buf, grub_size_t len, grub_off_t offset); - grub_err_t EXPORT_FUNC(grub_file_close) (grub_file_t file); static inline grub_off_t diff --git a/include/grub/misc.h b/include/grub/misc.h index bc725f9ca..8ec8ad822 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -192,7 +192,7 @@ grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n, grub_uint32_t d, grub_uint32_t *r); const char *EXPORT_FUNC(grub_gettext_dummy) (const char *s); -extern const char *(*EXPORT_VAR(grub_gettext)) (const char *s);// = grub_gettext_dummy; +extern const char *(*EXPORT_VAR(grub_gettext)) (const char *s); #ifdef NEED_ENABLE_EXECUTE_STACK void EXPORT_FUNC(__enable_execute_stack) (void *addr); diff --git a/kern/file.c b/kern/file.c index 00f69f05d..f713acbca 100644 --- a/kern/file.c +++ b/kern/file.c @@ -164,13 +164,3 @@ grub_file_seek (grub_file_t file, grub_off_t offset) file->offset = offset; return old; } - -grub_ssize_t -grub_file_pread (grub_file_t file, void *buf, grub_size_t len, grub_off_t offset) -{ - if (grub_file_seek (file, offset) == (grub_off_t)-1) - { - return -1; - } - return grub_file_read (file, buf, len); -}