Skip to content

Commit e498caf

Browse files
RestorerZchrisbra
andcommitted
patch 9.1.0173: msgfmt ver. 0.22 forcibly converts text to UTF-8
Problem: msgfmt ver. 0.22 forcibly converts text to UTF-8 Solution: use '--no-convert' if msgfmt supports it. Add a configure check for the msgfmt version (RestorerZ). closes: #14163 Co-authored-by: Christian Brabandt <cb@256bit.org> Signed-off-by: RestorerZ <restorer@mail2k.ru> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 9a660d2 commit e498caf

6 files changed

Lines changed: 63 additions & 29 deletions

File tree

src/auto/configure

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,7 @@ ac_subst_vars='LTLIBOBJS
650650
LIBOBJS
651651
LINK_AS_NEEDED
652652
DEPEND_CFLAGS_FILTER
653+
MSGFMTCMD
653654
MSGFMT_DESKTOP
654655
MAKEMO
655656
MSGFMT
@@ -15964,6 +15965,18 @@ printf "%s\n" "yes" >&6; }
1596415965
printf "%s\n" "no" >&6; }
1596515966
fi
1596615967

15968+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if msgfmt supports --no-convert" >&5
15969+
printf %s "checking if msgfmt supports --no-convert... " >&6; }
15970+
if "$MSGFMT" --help | grep -q -- '--no-convert' >/dev/null; then
15971+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
15972+
printf "%s\n" "yes" >&6; }
15973+
MSGFMTCMD="OLD_PO_FILE_INPUT=yes msgfmt --no-convert -v"
15974+
else
15975+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
15976+
printf "%s\n" "no" >&6; }
15977+
MSGFMTCMD="OLD_PO_FILE_INPUT=yes msgfmt -v"
15978+
fi
15979+
1596715980
fi
1596815981
else
1596915982
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no \"po/Makefile\" - disabled" >&5

src/config.mk.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ OS_EXTRA_OBJ = @OS_EXTRA_OBJ@
175175
MAKEMO = @MAKEMO@
176176

177177
MSGFMT = @MSGFMT@
178+
MSGFMTCMD = @MSGFMTCMD@
178179
MSGFMT_DESKTOP = @MSGFMT_DESKTOP@
179180

180181
### set if $SOURCE_DATE_EPOCH was set when running configure

src/configure.ac

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4523,6 +4523,15 @@ if test "$enable_nls" = "yes"; then
45234523
AC_MSG_RESULT([no])
45244524
fi
45254525
AC_SUBST(MSGFMT_DESKTOP)
4526+
AC_MSG_CHECKING([if msgfmt supports --no-convert])
4527+
if "$MSGFMT" --help | grep -q -- '--no-convert' >/dev/null; then
4528+
AC_MSG_RESULT([yes])
4529+
MSGFMTCMD="OLD_PO_FILE_INPUT=yes msgfmt --no-convert -v"
4530+
else
4531+
AC_MSG_RESULT([no])
4532+
MSGFMTCMD="OLD_PO_FILE_INPUT=yes msgfmt -v"
4533+
fi
4534+
AC_SUBST(MSGFMTCMD)
45264535
fi
45274536
else
45284537
AC_MSG_RESULT([no "po/Makefile" - disabled]);

src/po/Make_mvc.mak

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
!ENDIF
1313

1414
!IFNDEF LANGUAGE
15-
! IF [powershell.exe -nologo -noprofile $$lng=(Get-UICulture).TwoLetterISOLanguageName;$$Env:LANGUAGE=$$lng;Set-Content -Path .\lng.tmp -Value "LANGUAGE=$$lng"]
16-
#! IF [powershell.exe -nologo -noprofile -command $$Env:LANGUAGE=(Get-UICulture).TwoLetterISOLanguageName]
15+
! IF [powershell.exe -nologo -noprofile $$lng=(Get-UICulture).TwoLetterISOLanguageName; \
16+
$$Env:LANGUAGE=$$lng;Set-Content -Path .\lng.tmp -Value "LANGUAGE=$$lng"]
1717
! ENDIF
1818
# In order for the "install" and "cleanup-po" rule to work.
1919
# The others work with just setting the environment variable.
@@ -30,7 +30,7 @@
3030
! MESSAGE LANGUAGE is already set "$(LANGUAGE)"
3131
!ENDIF
3232

33-
# get LANGUAGES, MOFILES, MOCONVERTED and others
33+
# Get LANGUAGES, MOFILES, MOCONVERTED and others.
3434
!INCLUDE Make_all.mak
3535

3636
!IFNDEF VIMRUNTIME
@@ -46,7 +46,15 @@ VIM = ..\vim.exe
4646
# installed. Please do not put the path in quotes.
4747
GETTEXT_PATH = D:\Programs\GetText\bin
4848

49+
# Starting from version 0.22, msgfmt forcibly converts text to UTF-8 regardless
50+
# of the value of the "charset" field.
51+
!IF [%comspec% /v:on /e:on /c "for /F "tokens=4 delims= " %G in \
52+
('"$(GETTEXT_PATH)\msgfmt.exe" --version^|findstr /rc:[0-9^]\.[0-9^][0-9^]') do \
53+
@(set "v=%G" && if !v:~2^,2! GEQ 22 exit /b 1)"]
54+
MSGFMT = "$(GETTEXT_PATH)\msgfmt.exe" -v --no-convert
55+
!ELSE
4956
MSGFMT = "$(GETTEXT_PATH)\msgfmt.exe" -v
57+
!ENDIF
5058
XGETTEXT = "$(GETTEXT_PATH)\xgettext.exe"
5159
MSGMERGE = "$(GETTEXT_PATH)\msgmerge.exe"
5260

@@ -55,9 +63,9 @@ MSGMERGE = "$(GETTEXT_PATH)\msgmerge.exe"
5563
# If the "iconv" program is installed on the system, but it is not registered
5664
# in the %PATH% environment variable, then specify the full path to this file.
5765
!IF EXIST ("iconv.exe")
58-
ICONV = "iconv.exe"
66+
ICONV = iconv.exe
5967
!ELSEIF EXIST ("$(GETTEXT_PATH)\iconv.exe")
60-
ICONV="$(GETTEXT_PATH)\iconv.exe"
68+
ICONV = "$(GETTEXT_PATH)\iconv.exe"
6169
!ENDIF
6270

6371
# In case some package like GnuWin32, UnixUtils
@@ -133,7 +141,7 @@ ja.sjis.po: ja.po
133141
sjiscorr: sjiscorr.c
134142
$(CC) sjiscorr.c
135143

136-
# Convert ja.po to create ja.euc-jp.po
144+
# Convert ja.po to create ja.euc-jp.po.
137145
ja.euc-jp.po: ja.po
138146
-$(RM) $@
139147
!IF EXIST ("$(GETTEXT_PATH)\msgconv.exe")
@@ -313,7 +321,7 @@ zh_CN.cp936.po: zh_CN.UTF-8.po
313321
[System.IO.File]::WriteAllText(\"$@\", $$out, \
314322
[System.Text.Encoding]::GetEncoding(20936))
315323

316-
# Convert zh_TW.UTF-8.po to create zh_TW.po
324+
# Convert zh_TW.UTF-8.po to create zh_TW.po.
317325
zh_TW.po: zh_TW.UTF-8.po
318326
-$(RM) $@
319327
!IF EXIST ("$(GETTEXT_PATH)\msgconv.exe")
@@ -341,7 +349,7 @@ zh_TW.po: zh_TW.UTF-8.po
341349
[System.IO.File]::WriteAllText(\"$@\", $$out, \
342350
[System.Text.Encoding]::GetEncoding(950))
343351

344-
# Convert zh_TW.UTF-8.po to create zh_TW.po with backslash characters
352+
# Convert zh_TW.UTF-8.po to create zh_TW.po with backslash characters.
345353
# Requires doubling backslashes in the second byte. Don't depend on big5corr,
346354
# it should only be compiled when zh_TW.po is outdated.
347355

@@ -379,7 +387,7 @@ zh_TW.po: zh_TW.UTF-8.po
379387
# [System.IO.File]::WriteAllText(\"$@\", $$out, \
380388
# [System.Text.Encoding]::GetEncoding(950))
381389

382-
# see above in the zh_TW.po conversion section for backslashes.
390+
# See above in the zh_TW.po conversion section for backslashes.
383391
#big5corr: big5corr.c
384392
# $(CC) big5corr.c
385393

@@ -512,7 +520,7 @@ $(PACKAGE).pot: files
512520
# The files that are converted to a different encoding clearly state "DO NOT EDIT".
513521
update-po: $(MOFILES:.mo=)
514522

515-
# Don't add a dependency here, we only want to update the .po files manually
523+
# Don't add a dependency here, we only want to update the .po files manually.
516524
$(LANGUAGES):
517525
@$(MAKE) -nologo -f Make_mvc.mak GETTEXT_PATH="$(GETTEXT_PATH)" $(PACKAGE).pot
518526
$(CP) $@.po $@.po.orig
@@ -521,14 +529,14 @@ $(LANGUAGES):
521529
$(RM) $@.po.old
522530

523531
install: $(LANGUAGE).mo
524-
if not exist $(INSTALLDIR) $(MKD) $(INSTALLDIR)
525-
$(CP) $(LANGUAGE).mo $(INSTALLDIR)\$(PACKAGE).mo
532+
if not exist "$(INSTALLDIR)" $(MKD) "$(INSTALLDIR)"
533+
$(CP) $(LANGUAGE).mo "$(INSTALLDIR)\$(PACKAGE).mo"
526534

527535
install-all: all
528-
for %%l in ($(LANGUAGES)) do @if not exist $(VIMRUNTIME)\lang\%%l\LC_MESSAGES \
529-
$(MKD) $(VIMRUNTIME)\lang\%%l\LC_MESSAGES
536+
for %%l in ($(LANGUAGES)) do @if not exist "$(VIMRUNTIME)\lang\%%l\LC_MESSAGES" \
537+
$(MKD) "$(VIMRUNTIME)\lang\%%l\LC_MESSAGES"
530538
for %%l in ($(LANGUAGES)) do @$(CP) %%l.mo \
531-
$(VIMRUNTIME)\lang\%%l\LC_MESSAGES\$(PACKAGE).mo
539+
"$(VIMRUNTIME)\lang\%%l\LC_MESSAGES\$(PACKAGE).mo"
532540

533541
cleanup-po: $(LANGUAGE).po
534542
"$(VIM)" -u NONE -e -X -S cleanup.vim -c wq $(LANGUAGE).po

src/po/Makefile

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,25 @@
33
# Include stuff found by configure.
44
include ../auto/config.mk
55

6-
# get LANGUAGES, MOFILES, MOCONVERTED and others
6+
# Get LANGUAGES, MOFILES, MOCONVERTED and others.
77
include Make_all.mak
88

99
# Note: ja.sjis, *.cp1250 and zh_CN.cp936 are only for MS-Windows, they are
10-
# not installed on Unix
10+
# not installed on Unix.
1111

1212
PACKAGE = vim
1313
SHELL = /bin/sh
1414
VIM = ../vim
1515

16-
# MacOS sed is locale aware, set $LANG to avoid problems
16+
# MacOS sed is locale aware, set $LANG to avoid problems.
1717
SED = LANG=C sed
1818

1919
# The OLD_PO_FILE_INPUT and OLD_PO_FILE_OUTPUT are for the new GNU gettext
2020
# tools 0.10.37, which use a slightly different .po file format that is not
2121
# compatible with Solaris (and old gettext implementations) unless these are
2222
# set. gettext 0.10.36 will not work!
23-
MSGFMTCMD = OLD_PO_FILE_INPUT=yes $(MSGFMT) -v
23+
24+
# MSGFMTCMD is defined by Configure in ../auto/config.mk
2425
XGETTEXT = OLD_PO_FILE_INPUT=yes OLD_PO_FILE_OUTPUT=yes xgettext
2526
MSGMERGE = OLD_PO_FILE_INPUT=yes OLD_PO_FILE_OUTPUT=yes msgmerge
2627

@@ -45,7 +46,7 @@ converted: $(MOCONVERTED)
4546

4647
check: $(CHECKFILES)
4748

48-
# installing for real
49+
# Installing for real.
4950
install: $(MOFILES) $(MOCONVERTED)
5051
@$(MAKE) prefixcheck
5152
for lang in $(LANGUAGES); do \
@@ -71,7 +72,7 @@ uninstall:
7172
rm -f $(LOCALEDIR)/$$lang/LC_MESSAGES/$(PACKAGE).mo; \
7273
done
7374

74-
# installing for local tryout into ../../runtime/lang
75+
# Installing for local tryout into ../../runtime/lang.
7576
tryoutinstall: $(MOFILES) $(MOCONVERTED)
7677
@$(MAKE) prefixcheck
7778
for lang in $(LANGUAGES); do \
@@ -167,7 +168,7 @@ zh_CN.cp936.po: zh_CN.UTF-8.po
167168
-e 's/# Original translations/# Generated from $<, DO NOT EDIT/' \
168169
> $@
169170

170-
# Convert zh_TW.UTF-8.po to create zh_TW.po
171+
# Convert zh_TW.UTF-8.po to create zh_TW.po.
171172
zh_TW.po: zh_TW.UTF-8.po
172173
rm -f $@
173174
iconv -f UTF-8 -t BIG5 $< | \
@@ -176,7 +177,7 @@ zh_TW.po: zh_TW.UTF-8.po
176177
> $@
177178

178179

179-
# Convert zh_TW.UTF-8.po to create zh_TW.po with backslash characters
180+
# Convert zh_TW.UTF-8.po to create zh_TW.po with backslash characters.
180181
# Requires doubling backslashes in the second byte. Don't depend on big5corr,
181182
# it should only be compiled when zh_TW.po is outdated.
182183

@@ -200,7 +201,7 @@ zh_TW.po: zh_TW.UTF-8.po
200201

201202

202203
# 06.11.23, added by Restorer
203-
# see above in the zh_tw.po conversion section for backslashes.
204+
# See above in the zh_tw.po conversion section for backslashes.
204205
#big5corr: big5corr.c
205206
# $(CC) -o big5corr big5corr.c
206207

@@ -259,15 +260,15 @@ PO_INPUTLIST = \
259260
vim.desktop.in
260261

261262
$(PACKAGE).pot: $(PO_INPUTLIST) $(PO_VIM_INPUTLIST)
262-
# Convert the Vim scripts to (what looks like) Javascript
263+
# Convert the Vim scripts to (what looks like) Javascript.
263264
$(VIM) -u NONE --not-a-term -S tojavascript.vim $(PACKAGE).pot $(PO_VIM_INPUTLIST)
264-
# create vim.pot
265+
# Create vim.pot.
265266
$(XGETTEXT) --default-domain=$(PACKAGE) --add-comments \
266267
$(XGETTEXT_KEYWORDS) $(PO_INPUTLIST) $(PO_VIM_JSLIST)
267268
mv -f $(PACKAGE).po $(PACKAGE).pot
268-
# Fix Vim scripts names, so that "gf" works
269+
# Fix Vim scripts names, so that "gf" works.
269270
$(VIM) -u NONE --not-a-term -S fixfilenames.vim $(PACKAGE).pot $(PO_VIM_INPUTLIST)
270-
# Delete the temporary files
271+
# Delete the temporary files.
271272
rm *.js
272273

273274
vim.desktop: vim.desktop.in $(POFILES)
@@ -290,7 +291,7 @@ gvim.desktop: gvim.desktop.in $(POFILES) vim.desktop
290291
# The files that are converted to a different encoding clearly state "DO NOT EDIT".
291292
update-po: $(MOFILES:.mo=)
292293

293-
# Don't add a dependency here, we only want to update the .po files manually
294+
# Don't add a dependency here, we only want to update the .po files manually.
294295
$(LANGUAGES):
295296
@$(MAKE) $(PACKAGE).pot
296297
if test ! -f $@.po.orig; then cp $@.po $@.po.orig; fi

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
173,
707709
/**/
708710
172,
709711
/**/

0 commit comments

Comments
 (0)