diff options
author | Rüdiger Timm <rt@openoffice.org> | 2003-05-02 13:43:45 +0000 |
---|---|---|
committer | Rüdiger Timm <rt@openoffice.org> | 2003-05-02 13:43:45 +0000 |
commit | 59c3410f148912f6d74cfc07788dfa9befc50765 (patch) | |
tree | ccf20fb71d8b4b8ed58e56c5221c17353da0e8d1 /i18npool | |
parent | ed1491b3f96efe5d00fc127b4f550270cee91a52 (diff) |
INTEGRATION: CWS beta2regression03 (1.1.58); FILE MERGED
2003/04/30 15:35:19 er 1.1.58.1: #i13811# (not really); adapt to reality
Diffstat (limited to 'i18npool')
-rw-r--r-- | i18npool/source/localedata/data/currency-check.awk | 331 |
1 files changed, 202 insertions, 129 deletions
diff --git a/i18npool/source/localedata/data/currency-check.awk b/i18npool/source/localedata/data/currency-check.awk index 1a638797e10a..5d3b2fccc1b1 100644 --- a/i18npool/source/localedata/data/currency-check.awk +++ b/i18npool/source/localedata/data/currency-check.awk @@ -1,121 +1,192 @@ #!/usr/bin/gawk -f -#// Usage: gawk -f currency-check.awk *.xml -#// Check any -#// <FormatCode>...[$xxx-...]...</FormatCode> -#// against every -#// <CurrencySymbol>xxx</CurrencySymbol> -#// definition of the same XML file and output symbols if no match was found. -#// For formatindex="12" to formatindex="15" and for formatindex="17" it is -#// checked if the used currency symbol is the usedInCompatibleFormatCodes -#// currency symbol as it is needed by the number formatter. -#// Also generates output if the generic currency symbol (UTF8 string 0xC2A4) -#// is used instead of a real currency symbol. -#// Author: Eike Rathke <erack@sun.com> +# Usage: gawk -f currency-check.awk *.xml +# Check any +# <FormatCode>...[$xxx-...]...</FormatCode> +# against every +# <CurrencySymbol>xxx</CurrencySymbol> +# definition of the same XML file and output symbols if no match was found. +# For formatindex="12" to formatindex="15" and for formatindex="17" it is +# checked if the used currency symbol is the usedInCompatibleFormatCodes +# currency symbol as it is needed by the number formatter. +# Also generates output if the generic currency symbol (UTF8 string 0xC2A4) +# is used instead of a real currency symbol. +# Author: Eike Rathke <er@openoffice.org> BEGIN { - file = "" - while ( getline > 0 ) - { - if ( file != FILENAME ) - { - if ( file ) - checkIt() - file = FILENAME - line = 0 - nFormats = 0 - nSymbols = 0 - bSymbolDefault = 0 - bSymbolCompati = 0 - bFormatAuto = 0 - } - ++line - if ( $1 ~ /^<FormatElement$/ ) - { - if ( $5 ~ /^usage="CURRENCY"$/ ) - { - if ( $6 ~ /^formatindex="1[23457]">$/ ) - bFormatAuto = 1 - else - bFormatAuto = 0 - } - } - else if ( $0 ~ /^<FormatCode>.*\[\$.*-[0-9a-fA-F]+\]/ ) - { - split( $0, arr, /<|>/ ) - split( arr[3], code, /(\[\$)|(-[0-9a-fA-F]+\])/ ) - for ( j in code ) - { - if ( code[j] && code[j] !~ /\#|0/ ) - { - FormatLine[nFormats] = file " line " line - FormatAuto[nFormats] = bFormatAuto - Formats[nFormats++] = code[j] - } - } - bFormatAuto = 0 - } - else if ( $1 ~ /^<Currency$/ ) - { - if ( $2 ~ /^default="true"/ ) - bSymbolDefault = 1 - else - bSymbolDefault = 0 - if ( $3 ~ /^usedInCompatibleFormatCodes="true"/ ) - bSymbolCompati = 1 - else - bSymbolCompati = 0 - } - else if ( $0 ~ /^<CurrencySymbol>/ ) - { - split( $0, arr, /<|>/ ) - SymbolLine[nSymbols] = file " line " line - SymbolDefault[nSymbols] = bSymbolDefault - SymbolCompati[nSymbols] = bSymbolCompati - Symbols[nSymbols++] = arr[3] - bSymbolDefault = 0 - bSymbolCompati = 0 - } - } - checkIt() + file = "" +} + + +file != FILENAME { + if ( file ) + checkIt() + file = FILENAME + line = 0 + nFormats = 0 + nSymbols = 0 + bSymbolDefault = 0 + bSymbolCompati = 0 + bFormatAuto = 0 + sReplaceFrom = "" + sReplaceTo = "" + sMatchReplace = "" + sRefCurrencyFromLocale = "" +} + +{ + ++line + if ( $1 ~ /^<LC_FORMAT$/ ) + { + if ( $0 ~ /replaceFrom="\[CURRENCY\]"/ ) + { + sReplaceFrom = "\\[CURRENCY\\]" + sMatchReplace = "^<FormatCode>.*" sReplaceFrom + } + for ( j=2; j<=NF; ++j ) + { + if ( $j ~ /^replaceTo="/ ) + { + l = 12 + if ( $j ~ />$/ ) + ++l + if ( $j ~ /\/>$/ ) + ++l + sReplaceTo = substr( $j, 12, length($j)-l ) + } + } + } + else if ( $1 ~ /^<FormatElement$/ ) + { + if ( $0 ~ /usage="CURRENCY"/ ) + { + if ( $0 ~ /formatindex="1[23457]"/ ) + bFormatAuto = 1 + else + bFormatAuto = 0 + } + } + else if ( $0 ~ /^<FormatCode>.*\[\$.*-[0-9a-fA-F]+\]/ || + (sMatchReplace && $0 ~ sMatchReplace ) ) + { + if ( sReplaceFrom ) + gsub( sReplaceFrom, sReplaceTo ) + split( $0, arr, /<|>/ ) + split( arr[3], code, /(\[\$)|(-[0-9a-fA-F]+\])/ ) + for ( j in code ) + { + if ( code[j] && code[j] !~ /\#|0/ ) + { + FormatLine[nFormats] = file " line " line + FormatAuto[nFormats] = bFormatAuto + Formats[nFormats++] = code[j] + } + } + bFormatAuto = 0 + } + else if ( $1 ~ /^<LC_CURRENCY$/ ) + { + for ( j=2; j<=NF; ++j ) + { + if ( $j ~ /^ref="/ ) + { + l = 6 + if ( $j ~ />$/ ) + ++l + if ( $j ~ /\/>$/ ) + ++l + locale = substr( $j, 6, length($j)-l ) + sRefCurrencyFromLocale = file + oldfile = file + oldline = line + file = locale ".xml" + line = 0 + while ( (getline <file) > 0 ) + { + ++line + getCurrencyParams() + } + close( file ) + if ( !line ) + print "ref locale not available: " file \ + " (from " oldfile " line " oldline ")" + file = oldfile + line = oldline + sRefCurrencyFromLocale = "" + } + } + } + else + getCurrencyParams() } END { + if ( file ) + checkIt() +} + + +function getCurrencyParams() { + if ( $1 ~ /^<Currency$/ ) + { + if ( $0 ~ /default="true"/ ) + bSymbolDefault = 1 + else + bSymbolDefault = 0 + if ( $0 ~ /usedInCompatibleFormatCodes="true"/ ) + bSymbolCompati = 1 + else + bSymbolCompati = 0 + } + else if ( $0 ~ /^<CurrencySymbol>/ ) + { + split( $0, arr, /<|>/ ) + if ( sRefCurrencyFromLocale ) + SymbolLine[nSymbols] = file " line " line \ + " (referenced from " sRefCurrencyFromLocale ")" + else + SymbolLine[nSymbols] = file " line " line + SymbolDefault[nSymbols] = bSymbolDefault + SymbolCompati[nSymbols] = bSymbolCompati + Symbols[nSymbols++] = arr[3] + bSymbolDefault = 0 + bSymbolCompati = 0 + } } function checkIt() { - bad = 0 - for ( j=0; j<nFormats; ++j ) - { - state = FormatInSymbol( Formats[j] ) - if ( Formats[j] == "\xc2\xa4" ) - { - bad = 1 - print " bad: `" Formats[j] "' (" FormatLine[j] ")" - } - else if ( state == 0 ) - { - bad = 1 - print "unknown: `" Formats[j] "' (" FormatLine[j] ")" - } - else if ( FormatAuto[j] && state < 2 ) - { - bad = 1 - print "badauto: `" Formats[j] "' (" FormatLine[j] ")" - } - } - if ( bad ) - { - for ( j=0; j<nSymbols; ++j ) - { + bad = 0 + for ( j=0; j<nFormats; ++j ) + { + state = FormatInSymbol( Formats[j] ) + if ( Formats[j] == "\xc2\xa4" ) + { + bad = 1 + print " bad: `" Formats[j] "' (" FormatLine[j] ")" + } + else if ( state == 0 ) + { + bad = 1 + print "unknown: `" Formats[j] "' (" FormatLine[j] ")" + } + else if ( FormatAuto[j] && state < 2 ) + { + bad = 1 + print "badauto: `" Formats[j] "' (" FormatLine[j] ")" + } + } + if ( bad ) + { + for ( j=0; j<nSymbols; ++j ) + { bDef = 0 - if ( Symbols[j] == "\xc2\xa4" ) - print "def bad: `" Symbols[j] "' (" SymbolLine[j] ")" + if ( Symbols[j] == "\xc2\xa4" ) + print "def bad: `" Symbols[j] "' (" SymbolLine[j] ")" if ( SymbolDefault[j] ) { bDef = 1 - print "default: `" Symbols[j] "' (" SymbolLine[j] ")" + print "default: `" Symbols[j] "' (" SymbolLine[j] ")" } if ( SymbolCompati[j] ) { @@ -123,20 +194,20 @@ function checkIt() { print "compati: `" Symbols[j] "' (" SymbolLine[j] ")" } if ( !bDef ) - print "defined: `" Symbols[j] "' (" SymbolLine[j] ")" - } - } - else - { + print "defined: `" Symbols[j] "' (" SymbolLine[j] ")" + } + } + else + { bHasDefault = 0 bHasCompati = 0 - for ( j=0; j<nSymbols; ++j ) - { - if ( Symbols[j] == "\xc2\xa4" ) - { - bad = 1 - print "def bad: `" Symbols[j] "' (" SymbolLine[j] ")" - } + for ( j=0; j<nSymbols; ++j ) + { + if ( Symbols[j] == "\xc2\xa4" ) + { + bad = 1 + print "def bad: `" Symbols[j] "' (" SymbolLine[j] ")" + } if ( SymbolDefault[j] ) { if ( !bHasDefault ) @@ -157,7 +228,7 @@ function checkIt() { print "dupe compati: `" Symbols[j] "' (" SymbolLine[j] ")" } } - } + } if ( !bHasDefault ) { bad = 1 @@ -168,22 +239,24 @@ function checkIt() { bad = 1 print " no compati: (" file ")" } - } - if ( bad ) - print "" + } + if ( bad ) + print "" } function FormatInSymbol( format ) { - for ( nSym=0; nSym<nSymbols; ++nSym ) - { - if ( format == Symbols[nSym] ) - { + for ( nSym=0; nSym<nSymbols; ++nSym ) + { + if ( format == Symbols[nSym] ) + { if ( SymbolCompati[nSym] ) - return 2 - else - return 1 - } - } - return 0 + return 2 + else + return 1 + } + } + return 0 } + +# vim: ts=4 sw=4 expandtab |