disable the unrecognized nls flag
[AROS-Contrib.git] / regina / checkmts.rexx
blob636624ec7c56ab8ff888ebda236c8bbd782d9e3f
1 /*
2 * This program checks consistency of Regina source language files.
3 * All native language files are checked against the en.mts; its the
4 * master file
5 * 93.3 es
6 */
7 Parse Arg srcdir
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"
10 en. = ''
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
16 Call CheckHeader
17 Do j = 1 To Words( langs )
18 fn = Word( langs, j )'.mts'
19 If Stream( fn, 'C', 'QUERY EXISTS' ) \= '' Then
21 other. = ''
22 Call reader srcdir'/'fn, 0
23 If en.0 \= other.0 Then Call Abort fn, 1, 'Number of messages inconsistent'
24 Do i = 1 To en.0
25 If en.i \== other.i Then Call Abort fn, i, 'Mismatch of messages between:' '<'en.i'>' 'and' '<'other.i'>'
26 End
27 Say fn 'is clean'
28 End
29 End
30 Return 0
32 reader: Procedure Expose en. other.
33 Parse Arg fn, en
34 lineno = 0
35 idx = 0
36 If Stream( fn, 'C', 'QUERY EXISTS' ) = '' Then Call Abort fn, 0, 'Unable to find source file:' fn
37 Do While Lines(fn) > 0
38 lineno = lineno + 1
39 line = Linein( fn )
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'
44 sub = ''
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
49 Do Forever
50 Parse Var text '%' text
51 If text = '' Then Leave
52 subs = Left( text, 1 )
53 Select
54 When subs = '-' Then
56 sub = sub || ' '
57 say 'found %- at' lineno text
58 End
59 When subs = '%' Then text = Overlay( ' ', text, 1 )
60 When subs = ' ' Then Nop
61 Otherwise sub = sub || Left( text, 1 )
62 End
63 End
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'>'
69 idx = idx + 1
70 If en Then
72 en.idx = err'.'suberr sub
73 en.0 = idx
74 End
75 Else
77 other.idx = err'.'suberr sub
78 other.0 = idx
79 End
80 End
81 Return 0
83 CheckHeader:
84 fn = srcdir'/rexxmsg.h'
85 ok = 0
86 Do While Lines( fn ) > 0
87 line = Linein( fn )
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')'
92 ok = 1
93 Leave
94 End
95 End
96 If \ok Then Call Abort fn, 0, 'Unable to find definition of number of error messages in' fn
97 Return
99 Abort: Procedure
100 Parse Arg fn, lineno, msg
101 Say 'Error processing' fn 'at line:' lineno':' msg
102 Exit 1