2 * This program checks consistency of Regina source language files.
3 * All native language files are checked against the en.mts; its the
8 If srcdir
= '' Then Call Abort
'General', 0, 'Source directory not supply as 1st parameter'
9 langs
= "ca cs da de el es fi fr he hu is it ja ko lt nl no pl pt ru sk sl sv th tr zh"
11 Call reader srcdir
'/en.mts', 1
13 * Now we have the number of messages from the en.mts file, check this
14 * against the #define in rexxmsg.h
17 Do j
= 1 To Words( langs
)
18 fn
= Word( langs
, j
)'.mts'
19 If Stream( fn
, 'C', 'QUERY EXISTS' ) \
= '' Then
22 Call reader srcdir
'/'fn
, 0
23 If en
.0 \
= other
.0 Then Call Abort fn
, 1, 'Number of messages inconsistent'
25 If en
.i \
== other
.i
Then Call Abort fn
, i
, 'Mismatch of messages between:' '<'en
.i
'>' 'and' '<'other
.i
'>'
32 reader: Procedure Expose en
. other
.
36 If Stream( fn
, 'C', 'QUERY EXISTS' ) = '' Then Call Abort fn
, 0, 'Unable to find source file:' fn
37 Do While Lines(fn
) > 0
40 If Strip( line ) = '' | Left( line, 1 ) = '#' Then Iterate
41 Parse Var line err
',' suberr
',' text
'|' inserts
42 inserts
= Strip( inserts
)
43 If Datatype( err
) \
= 'NUM' | DataType( suberr
) \
= 'NUM' Then Call Abort fn
, lineno
, 'Invalid line format'
46 * parse the error text looking for constructs like %x
47 * if the 'x' is one of "sdcx', then include it in the further checking
50 Parse Var text
'%' text
51 If text
= '' Then Leave
52 subs
= Left( text
, 1 )
57 say 'found %- at' lineno text
59 When subs
= '%' Then text
= Overlay( ' ', text
, 1 )
60 When subs
= ' ' Then Nop
61 Otherwise sub
= sub
|| Left( text
, 1 )
65 * Now we have all of the substitutes, ensure that for each %x construct, there is
66 * an insert in inserts
68 If inserts \
= '' & Countstr( ',', inserts
) \
= Length( sub
) - 1 Then Call Abort fn
, lineno
, 'Incorrect number of inserts:' 1 + Countstr( ',', inserts
) 'for substitutions:' '<'sub
'>'
72 en
.idx
= err
'.'suberr sub
77 other
.idx
= err
'.'suberr sub
84 fn
= srcdir
'/rexxmsg.h'
86 Do While Lines( fn
) > 0
88 Parse Var line def
name num
89 If def
= '#define' & name = 'NUMBER_ERROR_MESSAGES' & Datatype( num
) = 'NUM' Then
91 If num \
= en
.0 Then Call Abort fn
, 0, 'Number of error messages defined in' fn
'('num
') is not the same as in message source files ('en
.0')'
96 If \ok
Then Call Abort fn
, 0, 'Unable to find definition of number of error messages in' fn
100 Parse Arg fn
, lineno
, msg
101 Say 'Error processing' fn
'at line:' lineno
':' msg