| 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 |
enp. = '' |
| 12 |
Call reader srcdir'/en.mts', 1 |
| 13 |
|
| 14 |
/* |
| 15 |
* Now we have the number of messages from the en.mts file, check this |
| 16 |
* against the #define in rexxmsg.h |
| 17 |
*/ |
| 18 |
Call CheckHeader |
| 19 |
Do j = 1 To Words( langs ) |
| 20 |
fn = Word( langs, j )'.mts' |
| 21 |
If Stream( srcdir'/'fn, 'C', 'QUERY EXISTS' ) \= '' Then |
| 22 |
Do |
| 23 |
other. = '' |
| 24 |
otherp. = '' |
| 25 |
Call reader srcdir'/'fn, 0 |
| 26 |
If en.0 \= other.0 Then Call Abort fn, 1, 'Number of messages inconsistent' |
| 27 |
Do i = 1 To en.0 |
| 28 |
If en.i \== other.i Then Call Abort fn, i, 'Mismatch of messages between:' '<'en.i'>' 'and' '<'other.i'>' |
| 29 |
End |
| 30 |
If enp.0 \= otherp.0 Then Call Abort fn, 1, 'Number of prefix messages inconsistent' |
| 31 |
Do i = 1 To enp.0 |
| 32 |
If enp.i \== otherp.i Then Call Abort fn, i, 'Mismatch of prefix messages between:' '<'enp.i'>' 'and' '<'otherp.i'>' |
| 33 |
End |
| 34 |
Say fn 'is clean' |
| 35 |
End |
| 36 |
End |
| 37 |
Return 0 |
| 38 |
|
| 39 |
reader: Procedure Expose en. other. enp. otherp. |
| 40 |
Parse Arg fn, en |
| 41 |
lineno = 0 |
| 42 |
idx = 0 |
| 43 |
idxp = 0 |
| 44 |
If Stream( fn, 'C', 'QUERY EXISTS' ) = '' Then Call Abort fn, 0, 'Unable to find source file:' fn |
| 45 |
Do While Lines(fn) > 0 |
| 46 |
lineno = lineno + 1 |
| 47 |
line = Linein( fn ) |
| 48 |
If Strip( line ) = '' | Left( line, 1 ) = '#' Then Iterate |
| 49 |
Parse Var line err ',' suberr ',' text '|' inserts |
| 50 |
inserts = Strip( inserts ) |
| 51 |
If ( Datatype( err ) \= 'NUM' & err \= 'P' ) | DataType( suberr ) \= 'NUM' Then Call Abort fn, lineno, 'Invalid line format' |
| 52 |
sub = '' |
| 53 |
/* |
| 54 |
* parse the error text looking for constructs like %x |
| 55 |
* if the 'x' is one of "sdcx', then include it in the further checking |
| 56 |
*/ |
| 57 |
Do Forever |
| 58 |
Parse Var text '%' text |
| 59 |
If text = '' Then Leave |
| 60 |
subs = Left( text, 1 ) |
| 61 |
Select |
| 62 |
When subs = '-' Then |
| 63 |
Do |
| 64 |
sub = sub || ' ' |
| 65 |
say 'found %- at' lineno text |
| 66 |
End |
| 67 |
When subs = '%' Then text = Overlay( ' ', text, 1 ) |
| 68 |
When subs = ' ' Then Nop |
| 69 |
Otherwise sub = sub || Left( text, 1 ) |
| 70 |
End |
| 71 |
End |
| 72 |
/* |
| 73 |
* Now we have all of the substitutes, ensure that for each %x construct, there is |
| 74 |
* an insert in inserts |
| 75 |
*/ |
| 76 |
If inserts \= '' & Countstr( ',', inserts ) \= Length( sub ) - 1 Then Call Abort fn, lineno, 'Incorrect number of inserts:' 1 + Countstr( ',', inserts ) 'for substitutions:' '<'sub'>' |
| 77 |
If err = 'P' Then idxp = idxp + 1 |
| 78 |
Else idx = idx + 1 |
| 79 |
If en Then |
| 80 |
Do |
| 81 |
If err = 'P' Then |
| 82 |
Do |
| 83 |
enp.idxp = err'.'suberr sub |
| 84 |
enp.0 = idxp |
| 85 |
End |
| 86 |
Else |
| 87 |
Do |
| 88 |
en.idx = err'.'suberr sub |
| 89 |
en.0 = idx |
| 90 |
End |
| 91 |
End |
| 92 |
Else |
| 93 |
Do |
| 94 |
If err = 'P' Then |
| 95 |
Do |
| 96 |
otherp.idxp = err'.'suberr sub |
| 97 |
otherp.0 = idxp |
| 98 |
End |
| 99 |
Else |
| 100 |
Do |
| 101 |
other.idx = err'.'suberr sub |
| 102 |
other.0 = idx |
| 103 |
End |
| 104 |
End |
| 105 |
End |
| 106 |
Return 0 |
| 107 |
|
| 108 |
CheckHeader: |
| 109 |
fn = srcdir'/rexxmsg.h' |
| 110 |
ok = 0 |
| 111 |
okp = 0 |
| 112 |
Do While Lines( fn ) > 0 |
| 113 |
line = Linein( fn ) |
| 114 |
Parse Var line def name num |
| 115 |
If def = '#define' & name = 'NUMBER_ERROR_MESSAGES' & Datatype( num ) = 'NUM' Then |
| 116 |
Do |
| 117 |
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')' |
| 118 |
ok = 1 |
| 119 |
Iterate |
| 120 |
End |
| 121 |
If def = '#define' & name = 'NUMBER_PREFIX_MESSAGES' & Datatype( num ) = 'NUM' Then |
| 122 |
Do |
| 123 |
If num \= enp.0 Then Call Abort fn, 0, 'Number of prefix messages defined in' fn '('num') is not the same as in message source files ('enp.0')' |
| 124 |
okp = 1 |
| 125 |
Iterate |
| 126 |
End |
| 127 |
End |
| 128 |
If \ok Then Call Abort fn, 0, 'Unable to find definition of number of error messages in' fn |
| 129 |
If \okp Then Call Abort fn, 0, 'Unable to find definition of number of prefix messages in' fn |
| 130 |
Return |
| 131 |
|
| 132 |
Abort: Procedure |
| 133 |
Parse Arg fn, lineno, msg |
| 134 |
Say 'Error processing' fn 'at line:' lineno':' msg |
| 135 |
Exit 1 |