@@ -30,36 +30,66 @@ func! GetMline()
30
30
return substitute (idline, ' [^%]*\(%[-+ #'' .0-9*]*l\=[dsuxXpoc%]\)\=' , ' \1' , ' g' )
31
31
endfunc
32
32
33
- " This only works when 'wrapscan' is set.
33
+ " This only works when 'wrapscan' is not set.
34
34
let s: save_wrapscan = &wrapscan
35
- set wrapscan
35
+ set nowrapscan
36
36
37
37
" Start at the first "msgid" line.
38
38
1
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.
41
43
let error = 0
42
44
43
45
while 1
44
46
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
+
46
65
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
56
70
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
57
87
endif
58
88
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
63
93
break
64
94
endif
65
95
endwhile
@@ -74,12 +104,16 @@ endwhile
74
104
"
75
105
1
76
106
if 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
79
111
endif
80
112
81
113
if error == 0
82
- echo " OK"
114
+ echomsg " OK"
115
+ else
116
+ exe error
83
117
endif
84
118
85
119
let &wrapscan = s: save_wrapscan
0 commit comments