Lech Lorens <[email protected]>:
> On 23-May-2010 Dominique Pellé <[email protected]> wrote:
>> James Vega wrote:
>>
>> > Since Vim can now open “largefiles” on 32-bit systems, there are some
>> > changes necessary to properly store/access the size of those files.
>> > This is easy to see as when you open a largefile, the status message
>> > showing the number of lines and characters in the file will have a
>> > negative number of characters for largefiles since the 32-bit long was
>> > overflowed.
>> >
>> > The attached patch (generated against 7d3cf4693a8f) changes the relevant
>> > buffer size pieces of the code to use off_t instead of long.
>> > Unfortunately, there isn't a standard way to format off_t for
>> > printf-style functions, so that required some preprocessor checks for
>> > what to use. There may be a better way to do that, but it worked for
>> > me.
>> >
>> > I've tested this on Windows with VS Express 2008 and Linux (both 32-bit
>> > and 64-bit environments).
>>
>>
>> Hi James
>>
>> This chunk...
>>
>> @@ -5062,7 +5062,7 @@
>> if (nchars == 1)
>> STRCPY(p, _("1 character"));
>> else
>> - sprintf((char *)p, _("%ld characters"), nchars);
>> + sprintf((char *)p, _(PRINTF_OFF_T" characters"), nchars);
>> }
>> }
>>
>> Changes the translated string in src/po/??.po files from:
>>
>> #, c-format
>> msgid "%ld characters"
>>
>> ... into:
>>
>> #, c-format
>>
>> Notice that the %ld has disappeared in the po file. Isn't it an issue?
>> msgid " characters"
>
> I don't think there is such a problem - «PRINTF_OFF_T" characters"»
> becomes a single string before the call to _() takes place. This string
> can either be:
> - "%ld characters"
> or
> - "%lld characters"
> This means, there are now two versions of the translated text possible
> which should be taken into account.
I still think it is a problem: at runtime, gettext() will be called with:
- gettext("%ld characters")
- or gettext("%lld characters")
However, the generated po file (generated with for example cd src/po ; make fr)
only contains the string " characters" after this patch. So gettext()
won't find the
translation and the English message will be displayed instead.
To confirm it, I just tried this:
$ cd vim/src
# Re-generate French po file
$ (cd src/po ; make fr)
# Rebuild vim & reinstall it (to install the translations)
$ make
$ make install
# Configure to see French translation for example:
$ export LANG=fr_FR.UTF-8
Now when I save a file with :saveas! foo I see the message only
partially translated (bug!):
"foo" 1 ligne, 4 characters écrit(s)
Notice the English word *characters* which did not get translated.
Before patch, I could see:
"foo" 1 ligne, 4 caractères écrit(s)
> The problem with this patch that I notice is a warning from gcc:
>
> gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_ATHENA -g -O2
> -D_FORTIFY_SOURCE=1 -o objects/fileio.o fileio.c
> fileio.c: In function ‘msg_add_lines’:
> fileio.c:5054: warning: format ‘%ld’ expects type ‘long int’, but argument 4
> has type ‘off_t’
> fileio.c:5065: warning: format ‘%ld’ expects type ‘long int’, but argument 3
> has type ‘off_t’
Yes, that's another problem. The idea of PRINTF_OFF_T was precisely
to avoid this kind of warning. But I also see the same warning on my laptop
(Ubuntu-9.10, gcc-4.4.1).
When using gcc, PRINTF_OFF_T should be defined to %zd to print
a off_t or a size_t type without warning. Configure script should check that
%zd works.
See:
http://stackoverflow.com/questions/586928/how-should-i-print-types-like-off-t-and-size-t
PRINTF_OFF_T is currently defined on my machine as %ld because
SIZEOF_OFF_T is not defined.
-- Dominique
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php