[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gettext: print_timeout
From: |
Carles Pina i Estany |
Subject: |
gettext: print_timeout |
Date: |
Sun, 13 Dec 2009 01:31:55 +0000 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
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
print_timeout.patch
Description: Text Data