@@ -30,36 +30,66 @@ func! GetMline()
3030 return substitute (idline, ' [^%]*\(%[-+ #'' .0-9*]*l\=[dsuxXpoc%]\)\=' , ' \1' , ' g' )
3131endfunc
3232
33- " This only works when 'wrapscan' is set.
33+ " This only works when 'wrapscan' is not set.
3434let s: save_wrapscan = &wrapscan
35- set wrapscan
35+ set nowrapscan
3636
3737" Start at the first "msgid" line.
38381
39- /^msgid
40- let startline = line (' .' )
39+ /^msgid\>
40+
41+ " When an error is detected this is set to the line number.
42+ " Note: this is used in the Makefile.
4143let error = 0
4244
4345while 1
4446 if getline (line (' .' ) - 1 ) !~ " no-c-format"
45- let fromline = GetMline ()
47+ " go over the "msgid" and "msgid_plural" lines
48+ let prevfromline = ' foobar'
49+ while 1
50+ let fromline = GetMline ()
51+ if prevfromline != ' foobar' && prevfromline != fromline
52+ echomsg ' Mismatching % in line ' . (line (' .' ) - 1 )
53+ echomsg ' msgid: ' . prevfromline
54+ echomsg ' msgid ' . fromline
55+ if error == 0
56+ let error = line (' .' )
57+ endif
58+ endif
59+ if getline (' .' ) !~ ' msgid_plural'
60+ break
61+ endif
62+ let prevfromline = fromline
63+ endwhile
64+
4665 if getline (' .' ) !~ ' ^msgstr'
47- echo ' Missing "msgstr" in line ' . line (' .' )
48- let error = 1
49- endif
50- let toline = GetMline ()
51- if fromline != toline
52- echo ' Mismatching % in line ' . (line (' .' ) - 1 )
53- echo ' msgid: ' . fromline
54- echo ' msgstr: ' . toline
55- let error = 1
66+ echomsg ' Missing "msgstr" in line ' . line (' .' )
67+ if error == 0
68+ let error = line (' .' )
69+ endif
5670 endif
71+
72+ " check all the 'msgstr' lines
73+ while getline (' .' ) = ~ ' ^msgstr'
74+ let toline = GetMline ()
75+ if fromline != toline
76+ echomsg ' Mismatching % in line ' . (line (' .' ) - 1 )
77+ echomsg ' msgid: ' . fromline
78+ echomsg ' msgstr: ' . toline
79+ if error == 0
80+ let error = line (' .' )
81+ endif
82+ endif
83+ if line (' .' ) == line (' $' )
84+ break
85+ endif
86+ endwhile
5787 endif
5888
59- " Find next msgid.
60- " Wrap around at the end of the file, quit when back at the first one.
61- /^msgid
62- if line (' .' ) == startline
89+ " Find next msgid. Quit when there is no more.
90+ let lnum = line ( ' . ' )
91+ silent ! /^msgid\>
92+ if line (' .' ) == lnum
6393 break
6494 endif
6595endwhile
@@ -74,12 +104,16 @@ endwhile
74104"
751051
76106if search (' msgid "\("\n"\)\?\([EW][0-9]\+:\).*\nmsgstr "\("\n"\)\?[^"]\@=\2\@!' ) > 0
77- echo ' Mismatching error/warning code in line ' . line (' .' )
78- let error = 1
107+ echomsg ' Mismatching error/warning code in line ' . line (' .' )
108+ if error == 0
109+ let error = line (' .' )
110+ endif
79111endif
80112
81113if error == 0
82- echo " OK"
114+ echomsg " OK"
115+ else
116+ exe error
83117endif
84118
85119let &wrapscan = s: save_wrapscan
0 commit comments