INTEGRATION: CWS locdat24 (1.5.212); FILE MERGED 2007/12/29 17:40:56 erack 1.5.212.1: joined from cws locales30

#!/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 <er@openoffice.org>

BEGIN {
    file = ""
}

file != FILENAME {
    if ( file )
        checkIt()
    file = FILENAME
    line = 0
    nFormats = 0
    nSymbols = 0
    bSymbolDefault = 0
    bSymbolCompati = 0
    bFormatAuto = 0
    sReplaceFrom = ""
    sReplaceTo = ""
    sMatchReplace = ""
    sRefCurrencyFromLocale = ""
    crlf = 0
}

{
    ++line
    # If run under Unix a CrLf spoils ...$ line end checks. DOS line endings
    # are boo anyways.
    if ( /\x0D$/ )
    {
        print "Error: not Unix line ending in line " line
        crlf = 1
        exit(1)
    }
    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 ~ /^[[:blank:]]*<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|\[NatNum/ )
            {
                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 && !crlf )
        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 ~ /^[[:blank:]]*<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 )
        {
            bDef = 0
            if ( Symbols[j] == "\xc2\xa4" )
                print "def bad: `" Symbols[j] "'   (" SymbolLine[j] ")"
            if ( SymbolDefault[j] )
            {
                bDef = 1
                print "default: `" Symbols[j] "'   (" SymbolLine[j] ")"
            }
            if ( SymbolCompati[j] )
            {
                bDef = 1
                print "compati: `" Symbols[j] "'   (" SymbolLine[j] ")"
            }
            if ( !bDef )
                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] ")"
            }
            if ( SymbolDefault[j] )
            {
                if ( !bHasDefault )
                    bHasDefault = 1
                else
                {
                    bad = 1
                    print "dupe default: `" Symbols[j] "'   (" SymbolLine[j] ")"
                }
            }
            if ( SymbolCompati[j] )
            {
                if ( !bHasCompati )
                    bHasCompati = 1
                else
                {
                    bad = 1
                    print "dupe compati: `" Symbols[j] "'   (" SymbolLine[j] ")"
                }
            }
        }
        if ( !bHasDefault )
        {
            bad = 1
            print "  no default: (" file ")"
        }
        if ( !bHasCompati )
        {
            bad = 1
            print "  no compati: (" file ")"
        }
    }
    if ( bad )
        print ""
}

function FormatInSymbol( format ) {
    for ( nSym=0; nSym<nSymbols; ++nSym )
    {
        if ( format == Symbols[nSym] )
        {
            if ( SymbolCompati[nSym] )
                return 2
            else
                return 1
        }
    }
    return 0
}

# vim: ts=4 sw=4 expandtab

#!/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 <er@openoffice.org>

BEGIN {
    file = ""
}

file != FILENAME {
    if ( file )
        checkIt()
    file = FILENAME
    line = 0
    nFormats = 0
    nSymbols = 0
    bSymbolDefault = 0
    bSymbolCompati = 0
    bFormatAuto = 0
    sReplaceFrom = ""
    sReplaceTo = ""
    sMatchReplace = ""
    sRefCurrencyFromLocale = ""
    crlf = 0
}

{
    ++line
    # If run under Unix a CrLf spoils ...$ line end checks. DOS line endings
    # are boo anyways.
    if ( /\x0D$/ )
    {
        print "Error: not Unix line ending in line " line
        crlf = 1
        exit(1)
    }
    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 ~ /^[[:blank:]]*<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|\[NatNum/ )
            {
                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 && !crlf )
        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 ~ /^[[:blank:]]*<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 )
        {
            bDef = 0
            if ( Symbols[j] == "\xc2\xa4" )
                print "def bad: `" Symbols[j] "'   (" SymbolLine[j] ")"
            if ( SymbolDefault[j] )
            {
                bDef = 1
                print "default: `" Symbols[j] "'   (" SymbolLine[j] ")"
            }
            if ( SymbolCompati[j] )
            {
                bDef = 1
                print "compati: `" Symbols[j] "'   (" SymbolLine[j] ")"
            }
            if ( !bDef )
                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] ")"
            }
            if ( SymbolDefault[j] )
            {
                if ( !bHasDefault )
                    bHasDefault = 1
                else
                {
                    bad = 1
                    print "dupe default: `" Symbols[j] "'   (" SymbolLine[j] ")"
                }
            }
            if ( SymbolCompati[j] )
            {
                if ( !bHasCompati )
                    bHasCompati = 1
                else
                {
                    bad = 1
                    print "dupe compati: `" Symbols[j] "'   (" SymbolLine[j] ")"
                }
            }
        }
        if ( !bHasDefault )
        {
            bad = 1
            print "  no default: (" file ")"
        }
        if ( !bHasCompati )
        {
            bad = 1
            print "  no compati: (" file ")"
        }
    }
    if ( bad )
        print ""
}

function FormatInSymbol( format ) {
    for ( nSym=0; nSym<nSymbols; ++nSym )
    {
        if ( format == Symbols[nSym] )
        {
            if ( SymbolCompati[nSym] )
                return 2
            else
                return 1
        }
    }
    return 0
}

# vim: ts=4 sw=4 expandtab


properly remove shite

properly remove shite

BEGIN {
  n_matches = 0;
  line_pos = 0;
  col_pos = 0;

  HINTS[0] = "p"
  HINTS[1] = "o"
  HINTS[2] = "i"
  HINTS[3] = "u"
  HINTS[4] = "l"
  HINTS[5] = "k"
  HINTS[6] = "j"
  HINTS[7] = "t"
  HINTS[8] = "r"
  HINTS[9] = "e"
  HINTS[10] = "wj"
  HINTS[11] = "wt"
  HINTS[12] = "wr"
  HINTS[13] = "we"
  HINTS[14] = "ww"
  HINTS[15] = "wq"
  HINTS[16] = "wf"
  HINTS[17] = "wd"
  HINTS[18] = "ws"
  HINTS[19] = "wa"
  HINTS[20] = "qp"
  HINTS[21] = "qo"
  HINTS[22] = "qi"
  HINTS[23] = "qu"
  HINTS[24] = "ql"
  HINTS[25] = "qk"
  HINTS[26] = "qj"
  HINTS[27] = "qt"
  HINTS[28] = "qr"
  HINTS[29] = "qe"
  HINTS[30] = "qw"
  HINTS[31] = "qq"
  HINTS[32] = "qf"
  HINTS[33] = "qd"
  HINTS[34] = "qs"
  HINTS[35] = "qa"
  HINTS[36] = "fp"
  HINTS[37] = "fo"
  HINTS[38] = "fi"
  HINTS[39] = "fu"
  HINTS[40] = "fl"
  HINTS[41] = "fk"
  HINTS[42] = "fj"
  HINTS[43] = "ft"
  HINTS[44] = "fr"
  HINTS[45] = "fe"
  HINTS[46] = "fw"
  HINTS[47] = "fq"
  HINTS[48] = "ff"
  HINTS[49] = "fd"
  HINTS[50] = "fs"
  HINTS[51] = "fa"
  HINTS[52] = "dp"
  HINTS[53] = "do"
  HINTS[54] = "di"
  HINTS[55] = "du"
  HINTS[56] = "dl"
  HINTS[57] = "dk"
  HINTS[58] = "dj"
  HINTS[59] = "dt"
  HINTS[60] = "dr"
  HINTS[61] = "de"
  HINTS[62] = "dw"
  HINTS[63] = "dq"
  HINTS[64] = "df"
  HINTS[65] = "dd"
  HINTS[66] = "ds"
  HINTS[67] = "da"
  HINTS[68] = "sp"
  HINTS[69] = "so"
  HINTS[70] = "si"
  HINTS[71] = "su"
  HINTS[72] = "sl"
  HINTS[73] = "sk"
  HINTS[74] = "sj"
  HINTS[75] = "st"
  HINTS[76] = "sr"
  HINTS[77] = "se"
  HINTS[78] = "sw"
  HINTS[79] = "sq"
  HINTS[80] = "sf"
  HINTS[81] = "sd"
  HINTS[82] = "ss"
  HINTS[83] = "sa"
  HINTS[84] = "ap"
  HINTS[85] = "ao"
  HINTS[86] = "ai"
  HINTS[87] = "au"
  HINTS[88] = "al"
  HINTS[89] = "ak"
  HINTS[90] = "aj"
  HINTS[91] = "at"
  HINTS[92] = "ar"
  HINTS[93] = "ae"
  HINTS[94] = "aw"
  HINTS[95] = "aq"
  HINTS[96] = "af"
  HINTS[97] = "ad"
  HINTS[98] = "as"
  HINTS[99] = "aa"

  finger_patterns = ENVIRON["FINGER_PATTERNS"];

  hint_format = "\033[1;33m[%s]\033[0m"
  highlight_format = "\033[1;33m%s\033[0m "
  hint_lookup = ""
}

{
  line = $0;
  pos = 0;
  col_pos = 0;
	col_pos_correction = 0;

	output_line = line;

  while (match(line, finger_patterns)) {
    n_matches += 1;

		hint = HINTS[n_matches - 1]
    pos += RSTART;

    col_pos = pos;
    line_match = substr(line, RSTART, RLENGTH);

    col_pos = col_pos + col_pos_correction

    line_pos = NR;

		pre_match = substr(output_line, 0, col_pos - 1);
    hint_match = sprintf(highlight_format hint_format, line_match, hint);
		post_match = substr(output_line, col_pos + RLENGTH, length(line) - 1);

    output_line = pre_match hint_match post_match;

    line = post_match;

    col_pos_correction += (length(sprintf(highlight_format, line_match)) - 1 + length(sprintf(hint_format, hint)) - 1) + 1;

    hint_lookup = hint_lookup hint ":" line_match "\n"
  }

  printf "\n%s", output_line
}

END {
  print hint_lookup | "cat 1>&3"
}

BEGIN {
  n_matches = 0;
  line_pos = 0;
  col_pos = 0;

  HINTS[0] = "p"
  HINTS[1] = "o"
  HINTS[2] = "i"
  HINTS[3] = "u"
  HINTS[4] = "l"
  HINTS[5] = "k"
  HINTS[6] = "j"
  HINTS[7] = "t"
  HINTS[8] = "r"
  HINTS[9] = "e"
  HINTS[10] = "wj"
  HINTS[11] = "wt"
  HINTS[12] = "wr"
  HINTS[13] = "we"
  HINTS[14] = "ww"
  HINTS[15] = "wq"
  HINTS[16] = "wf"
  HINTS[17] = "wd"
  HINTS[18] = "ws"
  HINTS[19] = "wa"
  HINTS[20] = "qp"
  HINTS[21] = "qo"
  HINTS[22] = "qi"
  HINTS[23] = "qu"
  HINTS[24] = "ql"
  HINTS[25] = "qk"
  HINTS[26] = "qj"
  HINTS[27] = "qt"
  HINTS[28] = "qr"
  HINTS[29] = "qe"
  HINTS[30] = "qw"
  HINTS[31] = "qq"
  HINTS[32] = "qf"
  HINTS[33] = "qd"
  HINTS[34] = "qs"
  HINTS[35] = "qa"
  HINTS[36] = "fp"
  HINTS[37] = "fo"
  HINTS[38] = "fi"
  HINTS[39] = "fu"
  HINTS[40] = "fl"
  HINTS[41] = "fk"
  HINTS[42] = "fj"
  HINTS[43] = "ft"
  HINTS[44] = "fr"
  HINTS[45] = "fe"
  HINTS[46] = "fw"
  HINTS[47] = "fq"
  HINTS[48] = "ff"
  HINTS[49] = "fd"
  HINTS[50] = "fs"
  HINTS[51] = "fa"
  HINTS[52] = "dp"
  HINTS[53] = "do"
  HINTS[54] = "di"
  HINTS[55] = "du"
  HINTS[56] = "dl"
  HINTS[57] = "dk"
  HINTS[58] = "dj"
  HINTS[59] = "dt"
  HINTS[60] = "dr"
  HINTS[61] = "de"
  HINTS[62] = "dw"
  HINTS[63] = "dq"
  HINTS[64] = "df"
  HINTS[65] = "dd"
  HINTS[66] = "ds"
  HINTS[67] = "da"
  HINTS[68] = "sp"
  HINTS[69] = "so"
  HINTS[70] = "si"
  HINTS[71] = "su"
  HINTS[72] = "sl"
  HINTS[73] = "sk"
  HINTS[74] = "sj"
  HINTS[75] = "st"
  HINTS[76] = "sr"
  HINTS[77] = "se"
  HINTS[78] = "sw"
  HINTS[79] = "sq"
  HINTS[80] = "sf"
  HINTS[81] = "sd"
  HINTS[82] = "ss"
  HINTS[83] = "sa"
  HINTS[84] = "ap"
  HINTS[85] = "ao"
  HINTS[86] = "ai"
  HINTS[87] = "au"
  HINTS[88] = "al"
  HINTS[89] = "ak"
  HINTS[90] = "aj"
  HINTS[91] = "at"
  HINTS[92] = "ar"
  HINTS[93] = "ae"
  HINTS[94] = "aw"
  HINTS[95] = "aq"
  HINTS[96] = "af"
  HINTS[97] = "ad"
  HINTS[98] = "as"
  HINTS[99] = "aa"

  finger_patterns = ENVIRON["FINGER_PATTERNS"];

  hint_format = "\033[1;33m[%s]\033[0m"
  highlight_format = "\033[1;33m%s\033[0m "
  printf "%s\n", finger_patterns | "cat 1>&4"
  hint_lookup = ""
}

{
  line = $0;
  pos = 0;
  col_pos = 0;
	col_pos_correction = 0;

	output_line = line;

  while (match(line, finger_patterns)) {
    n_matches += 1;

		hint = HINTS[n_matches - 1]
    pos += RSTART;

    col_pos = pos;
    line_match = substr(line, RSTART, RLENGTH);

    col_pos = col_pos + col_pos_correction

    line_pos = NR;

		pre_match = substr(output_line, 0, col_pos - 1);
    hint_match = sprintf(highlight_format hint_format, line_match, hint);
		post_match = substr(output_line, col_pos + RLENGTH, length(line) - 1);

    output_line = pre_match hint_match post_match;

    line = post_match;

    col_pos_correction += (length(sprintf(highlight_format, line_match)) - 1 + length(sprintf(hint_format, hint)) - 1) + 1;

    hint_lookup = hint_lookup hint ":" line_match "\n"
  }

  printf "\n%s", output_line
}

END {
  print hint_lookup | "cat 1>&3"
}


rnc2rng.awk: Support "empty"

rnc2rng.awk: Support "empty"

#!/bin/awk
# -*- indent-tabs-mode: nil; c-basic-offset: 2 -*-
# rnc2rng.awk - Convert RELAX NG Compact Syntax to XML Syntax
# Copyright (C) 2007 Shaun McCance <shaunm@gnome.org>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

# This program is free software, but that doesn't mean you should use it.
# I wanted to write and maintain the Mallard schema in RNC in code blocks
# within the specification, but I needed to distribute the schema in RNG.
# Since xmllint (libxml2) does not currently support RNC, and since I'm
# not willing to introduce more dependencies, awk was my only option.
#
# This awk script is *NOT* a complete implementation, and probably never
# will be.  Its sole purpose is to handle the Mallard schema, and it is
# sufficient for that task.
#
# You are, of course, free to use any of this.  If you do proliferate this
# hack, it is requested (though not required, that would be non-free) that
# you atone for your actions.  A good atonement would be contributing to
# free software.

function parse_pattern (line) {
  sub(/^ */, "", line)
  if (length(line) == 0) return;
  c = substr(line, 1, 1);
  if (c == "(" || c == "{") {
    stack[++stack_i] = substr(line, 1, 1);
    paren[++paren_i] = stack_i;
    if (length(line) >= 2)
      parse_pattern(substr(line, 2));
  }
  else if (c == ")" || c == "}") {
    open = stack[paren[paren_i]];
    oc = substr(open, 1, 1) c;
    if (oc != "()" && oc != "{}") {
      print "Mismatched parentheses on line " FNR | "cat 1>&2";
      error = 1;
      exit 1
    }

    tag = "";
    if (length(open) > 1 && substr(open, 2, 1) == "&") {
      tag = "interleave";
    }
    else if (length(open) > 1 && substr(open, 2, 1) == "|") {
      tag = "choice";
    }
    else if (oc == "()") {
      tag = "group";
    }

    tmp = "";
    if (tag != "") {
      tmp = "<" tag ">";
    }
    for (i = paren[paren_i] + 1; i <= stack_i; i++) {
      tmp = tmp stack[i] "\n";
    }
    if (tag != "") {
      tmp = tmp "</" tag ">";
    }
    stack_i = paren[paren_i];
    stack[stack_i] = tmp;
    paren_i--;

    if (oc == "{}") {
      if (match(stack[stack_i - 1], "^<element")) {
        tmp = stack[stack_i - 1] "\n";
        if (stack[stack_i] != "") {
          tmp = tmp stack[stack_i] "\n";
        } else {
          tmp = tmp "<empty/>\n";
        }
        tmp = tmp "</element>";
        stack[--stack_i] = tmp;
      }
      else if (match(stack[stack_i - 1], "^<attribute")) {
        tmp = stack[stack_i - 1] "\n";
        if (stack[stack_i] != "") {
          tmp = tmp stack[stack_i] "\n";
        } else {
          tmp = tmp "<empty/>\n";
        }
        tmp = tmp "</attribute>";
        stack[--stack_i] = tmp;
      }
      else if (stack[stack_i - 1] == "<list>") {
        tmp = stack[stack_i - 1] "\n";
        tmp = tmp stack[stack_i] "\n";
        tmp = tmp "</list>";
        stack[--stack_i] = tmp;
      }
      else if (stack[stack_i - 1] == "<mixed>") {
        tmp = stack[stack_i - 1] "\n";
        tmp = tmp stack[stack_i] "\n";
        tmp = tmp "</mixed>";
        stack[--stack_i] = tmp;
      }
    }
    if (paren_i == 0) {
      mode = "grammar";
    }
    if (length(line) >= 2)
      parse_pattern(substr(line, 2));
  }
  else if (c == "|" || c == "&" || c == ",") {
    if (length(stack[paren[paren_i]]) == 1) {
      stack[paren[paren_i]] = stack[paren[paren_i]] c;
    }
    else if (length(stack[paren[paren_i]]) < 2 || substr(stack[paren[paren_i]], 2) != c) {
      print "Mismatched infix operators on line " FNR | "cat 1>&2";
      error = 1;
      exit 1
    }
    if (length(line) >= 2)
      parse_pattern(substr(line, 2));
  }
  else if (c == "?") {
    stack[stack_i] = "<optional>" stack[stack_i] "</optional>"
    if (length(line) >= 2)
      parse_pattern(substr(line, 2));
  }
  else if (c == "*") {
    stack[stack_i] = "<zeroOrMore>" stack[stack_i] "</zeroOrMore>"
    if (length(line) >= 2)
      parse_pattern(substr(line, 2));
  }
  else if (c == "+") {
    stack[stack_i] = "<oneOrMore>" stack[stack_i] "</oneOrMore>"
    if (length(line) >= 2)
      parse_pattern(substr(line, 2));
  }
  else if (c == "\"") {
    txt = substr(line, 2);
    sub(/".*/, "", txt)
    stack[++stack_i] = "<value>" txt "</value>";
    if (length(line) >= length(txt) + 3)
      parse_pattern(substr(line, length(txt) + 3));
  }
  else if (match(line, "^element ")) {
    aft = substr(line, 8);
    sub(/^ */, "", aft);
    name = aft;
    stack[++stack_i] = "<element";
    mode = "name_class";
    name_class_i = stack_i;
    parse_name_class(name);
  }
  else if (match(line, "^attribute ")) {
    aft = substr(line, 10);
    sub(/^ */, "", aft);
    name = aft;
    stack[++stack_i] = "<attribute";
    mode = "name_class";
    name_class_i = stack_i;
    parse_name_class(name);
  }
  else if (match(line, "^list ")) {
    aft = substr(line, 5);
    sub(/^ */, "", aft);
    stack[++stack_i] = "<list>";
    if (aft != "") { parse_pattern(aft); }
  }
  else if (match(line, "^mixed ")) {
    aft = substr(line, 6);
    sub(/^ */, "", aft);
    stack[++stack_i] = "<mixed>";
    if (aft != "") { parse_pattern(aft); }
  }
  else if (match(line, /^text[^A-Za-z]/) || match(line, /^text$/)) {
    stack[++stack_i] = "<text/>";
    aft = substr(line, 5);
    sub(/^ */, "", aft);
    if (aft != "") { parse_pattern(aft); }
  }
  else if (match(line, "^default namespace ")) {
    print "default namespace appeared out of context on line " FNR | "cat 1>&2";
    error = 1;
    exit 1
  }
  else if (match(line, "^namespace ")) {
    print "namespace appeared out of context on line " FNR | "cat 1>&2";
    error = 1;
    exit 1
  }
  else if (match(line, "^start ")) {
    print "start appeared out of context on line " FNR | "cat 1>&2";
    error = 1;
    exit 1
  }
  else if (match(line, /^xsd:[A-Za-z_]/)) {
    name = substr(line, 1);
    sub(/^xsd:/, "", name);
    sub(/[^A-Za-z_]+.*/, "", name);
    stack[++stack_i] = sprintf("<data type='%s' datatypeLibrary='http://www.w3.org/2001/XMLSchema-datatypes'/>",
                               name);
    if (length(line) >= length(name) + 5) {
      aft = substr(line, length(name) + 5);
      parse_pattern(aft);
    }
  }
  else if (match(line, /^[A-Za-z_]/)) {
    name = substr(line, 1);
    sub(/[^A-Za-z_]+.*/, "", name);
    if (name == "empty") {
      stack[++stack_i] = "<empty/>";
    }
    else {
      stack[++stack_i] = sprintf("<ref name='%s'/>", name);
    }
    if (length(line) >= length(name) + 1) {
      aft = substr(line, length(name) + 1);
      parse_pattern(aft);
    }
  }
}

function parse_name_class (line) {
  sub(/^ */, "", line)
  if (length(line) == 0) return;
  c = substr(line, 1, 1);
  if (c == "{") {
    if (stack_i != name_class_i) {
      tmp = "";
      for (i = stack_i; i >= name_class_i; i--) {
        if (stack[i] == "<except>") {
          tmp = "<except>" tmp "</except>";
        }
        else if (stack[i] == "<anyName>") {
          tmp = "<anyName>" tmp "</anyName>";
        }
        else {
          tmp = stack[i] tmp
        }
      }
      stack[name_class_i] = tmp;
      stack_i = name_class_i;
    }
    mode = "pattern";
    parse_pattern(line);
  }
  else if (c == "*") {
    if (stack[stack_i] == "<element" || stack[stack_i] == "<attribute") {
      stack[stack_i] = stack[stack_i] ">";
    }
    stack[++stack_i] = "<anyName>";
    parse_name_class(substr(line, 2));
  }
  else if (c == "-") {
    stack[++stack_i] = "<except>"
    parse_name_class(substr(line, 2));
  }
  else if (c == "|") {
    if (length(stack[paren[paren_i]]) == 1) {
      stack[paren[paren_i]] = stack[paren[paren_i]] c;
    }
    else if (substr(stack[paren[paren_i]], 2) != "|") {
      print "Mismatched infix operators on line " FNR | "cat 1>&2";
      error = 1;
      exit 1
    }
    parse_name_class(substr(line, 2));
  }
  else if (c == "(") {
    stack[++stack_i] = "(";
    paren[++paren_i] = stack_i;
    parse_name_class(substr(line, 2));
  }
  else if (c == ")") {
    open = stack[paren[paren_i]];
    if (substr(open, 1, 1) != "(") {
      print "Mismatched parentheses on line " FNR | "cat 1>&2";
      error = 1;
      exit 1
    }
    if (length(open) == 1 || substr(open, 2, 1) != "|") {
      print "Unknown name class pattern on line " FNR | "cat 1>&2";
      error = 1;
      exit 1
    }
    tmp = ""
    for (i = paren[paren_i] + 1; i <= stack_i; i++) {
      tmp = tmp stack[i] "\n";
    }
    stack_i = paren[paren_i];
    stack[stack_i] = tmp;
    paren_i--;
    parse_name_class(substr(line, 2));
  }
  else if (match(line, /^[A-Za-z_]/)) {
    name = substr(line, 1);
    sub(/[^A-Za-z_]+.*/, "", name);
    if (length(line) >= length(name) + 1)
      aft = substr(line, length(name) + 1);
    else
      aft = "";
    if (length(aft) >= 2 && substr(aft, 1, 2) == ":*") {
      for (i = 1; i <= namespaces_i; i++) {
        if (nsnames[i] == name) {
          stack[++stack_i] = sprintf("<nsName ns='%s'/>", namespaces[i])
          break;
        }
      }
      if (length(aft) >= 3)
        aft = substr(aft, 3);
      else
        aft = "";
    }
    else {
      if (length(aft) >= 2 && substr(aft, 1, 1) == ":") {
        checkns = "";
        pos = 1;
        while (pos <= namespaces_i) {
          if (namespaces[pos] != "" && nsnames[pos] == name) {
            checkns = namespaces[pos];
            break;
          }
          pos++;
        }
        if (checkns == "") {
          print "Unknown namespace prefix " name " on line " FNR | "cat 1>&2";
          error = 1;
          exit 1
        }
        localname = substr(aft, 2);
        sub(/[^A-Za-z_]+.*/, "", localname);
        if (length(aft) >= length(localname) + 2)
          aft = substr(aft, length(localname) + 2);
        else
          aft = "";
        name = name ":" localname;
      }
      if (stack[stack_i] == "<element" || stack[stack_i] == "<attribute") {
        stack[stack_i] = stack[stack_i] sprintf(" name='%s'>", name);
      }
      else {
        stack[++stack_i] = sprintf("<name>%s</name>", name);
      }
    }
    parse_name_class(aft);
  }
}

function printstack () {
  pos = 1;
  while (pos <= stack_i) {
    printstackone();
  }
}
function printstackone () {
  if (substr(stack[pos], 1, 6) == "<start") {
    print stack[pos];
    pos++;
    printstackone();
    print "</start>"
  }
  else if (substr(stack[pos], 1, 7) == "<define") {
    print stack[pos];
    pos++;
    printstackone();
    print "</define>"
  }
  else {
    print stack[pos];
    pos++;
  }
}

BEGIN {
  mode = "grammar";
  stack_i = 0;
  paren_i = 0;
  namespaces_i = 0;
  error = 0;
}

END {
  if (!error) {
    print "<grammar xmlns='http://relaxng.org/ns/structure/1.0'";
    pos = 1;
    while (pos <= namespaces_i) {
      if (namespaces[pos] != "") {
        printf " xmlns:%s='%s'", nsnames[pos], namespaces[pos];
      }
      pos++;
    }
    printf " ns='%s'>\n", default_namespace;
    printstack()
    print "</grammar>"
  }
}

mode == "pattern" && paren_i == 0 && /.*=/ { mode = "grammar"; }
mode == "grammar" && /.*=/ {
  if (match($0, "^default namespace ")) {
    namespace = substr($0, index($0, "=") + 1);
    nsname = substr($0, 19, index($0, "=") - 19);
    sub(/^ */, "", nsname);
    sub(/ *$/, "", nsname);
    sub(/^ *"/, "", namespace);
    sub(/" *$/, "", namespace);
    if (nsname != "") {
      nsnames[++namespaces_i] = nsname;
      namespaces[namespaces_i] = namespace;
    }
    default_namespace = namespace
  }
  else if (match($0, "^namespace ")) {
    namespace = substr($0, index($0, "=") + 1);
    nsname = substr($0, 11, index($0, "=") - 11);
    sub(/^ */, "", nsname);
    sub(/ *$/, "", nsname);
    sub(/^ *"/, "", namespace);
    sub(/" *$/, "", namespace);
    if (nsname != "") {
      nsnames[++namespaces_i] = nsname;
      namespaces[namespaces_i] = namespace;
    }
  }
  else {
    nameix = index($0, "=");
    combine = "";
    if (nameix < 1) next;
    if (substr($0, nameix - 1, 1) == "|") {
      combine = "choice";
      name = substr($0, 1, nameix - 2);
    }
    else if (substr($0, nameix - 1, 1) == "&") {
      combine = "interleave";
      name = substr($0, 1, nameix - 2);
    }
    else {
      name = substr($0, 1, nameix - 1);
    }
    sub(/ /, "", name);
    if (name == "start")
      stack[++stack_i] = "<start>"
    else {
      define = sprintf("<define name='%s'", name);
      if (combine != "")
        define = define " combine='" combine "'"
      define = define ">"
      stack[++stack_i] = define;
    }
    mode = "pattern";
    if (length($0) >= nameix + 1)
      parse_pattern(substr($0, nameix + 1))
  }
  next;
}
mode == "pattern" {
  parse_pattern($0);
  next;
}
mode == "name_class" {
  parse_name_class($0);
  next;
}

#!/bin/awk
# -*- indent-tabs-mode: nil; c-basic-offset: 2 -*-
# rnc2rng.awk - Convert RELAX NG Compact Syntax to XML Syntax
# Copyright (C) 2007 Shaun McCance <shaunm@gnome.org>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

# This program is free software, but that doesn't mean you should use it.
# I wanted to write and maintain the Mallard schema in RNC in code blocks
# within the specification, but I needed to distribute the schema in RNG.
# Since xmllint (libxml2) does not currently support RNC, and since I'm
# not willing to introduce more dependencies, awk was my only option.
#
# This awk script is *NOT* a complete implementation, and probably never
# will be.  Its sole purpose is to handle the Mallard schema, and it is
# sufficient for that task.
#
# You are, of course, free to use any of this.  If you do proliferate this
# hack, it is requested (though not required, that would be non-free) that
# you atone for your actions.  A good atonement would be contributing to
# free software.

function parse_pattern (line) {
  sub(/^ */, "", line)
  if (length(line) == 0) return;
  c = substr(line, 1, 1);
  if (c == "(" || c == "{") {
    stack[++stack_i] = substr(line, 1, 1);
    paren[++paren_i] = stack_i;
    if (length(line) >= 2)
      parse_pattern(substr(line, 2));
  }
  else if (c == ")" || c == "}") {
    open = stack[paren[paren_i]];
    oc = substr(open, 1, 1) c;
    if (oc != "()" && oc != "{}") {
      print "Mismatched parentheses on line " FNR | "cat 1>&2";
      error = 1;
      exit 1
    }

    tag = "";
    if (length(open) > 1 && substr(open, 2, 1) == "&") {
      tag = "interleave";
    }
    else if (length(open) > 1 && substr(open, 2, 1) == "|") {
      tag = "choice";
    }
    else if (oc == "()") {
      tag = "group";
    }

    tmp = "";
    if (tag != "") {
      tmp = "<" tag ">";
    }
    for (i = paren[paren_i] + 1; i <= stack_i; i++) {
      tmp = tmp stack[i] "\n";
    }
    if (tag != "") {
      tmp = tmp "</" tag ">";
    }
    stack_i = paren[paren_i];
    stack[stack_i] = tmp;
    paren_i--;

    if (oc == "{}") {
      if (match(stack[stack_i - 1], "^<element")) {
        tmp = stack[stack_i - 1] "\n";
        if (stack[stack_i] != "") {
          tmp = tmp stack[stack_i] "\n";
        } else {
          tmp = tmp "<empty/>\n";
        }
        tmp = tmp "</element>";
        stack[--stack_i] = tmp;
      }
      else if (match(stack[stack_i - 1], "^<attribute")) {
        tmp = stack[stack_i - 1] "\n";
        if (stack[stack_i] != "") {
          tmp = tmp stack[stack_i] "\n";
        } else {
          tmp = tmp "<empty/>\n";
        }
        tmp = tmp "</attribute>";
        stack[--stack_i] = tmp;
      }
      else if (stack[stack_i - 1] == "<list>") {
        tmp = stack[stack_i - 1] "\n";
        tmp = tmp stack[stack_i] "\n";
        tmp = tmp "</list>";
        stack[--stack_i] = tmp;
      }
      else if (stack[stack_i - 1] == "<mixed>") {
        tmp = stack[stack_i - 1] "\n";
        tmp = tmp stack[stack_i] "\n";
        tmp = tmp "</mixed>";
        stack[--stack_i] = tmp;
      }
    }
    if (paren_i == 0) {
      mode = "grammar";
    }
    if (length(line) >= 2)
      parse_pattern(substr(line, 2));
  }
  else if (c == "|" || c == "&" || c == ",") {
    if (length(stack[paren[paren_i]]) == 1) {
      stack[paren[paren_i]] = stack[paren[paren_i]] c;
    }
    else if (length(stack[paren[paren_i]]) < 2 || substr(stack[paren[paren_i]], 2) != c) {
      print "Mismatched infix operators on line " FNR | "cat 1>&2";
      error = 1;
      exit 1
    }
    if (length(line) >= 2)
      parse_pattern(substr(line, 2));
  }
  else if (c == "?") {
    stack[stack_i] = "<optional>" stack[stack_i] "</optional>"
    if (length(line) >= 2)
      parse_pattern(substr(line, 2));
  }
  else if (c == "*") {
    stack[stack_i] = "<zeroOrMore>" stack[stack_i] "</zeroOrMore>"
    if (length(line) >= 2)
      parse_pattern(substr(line, 2));
  }
  else if (c == "+") {
    stack[stack_i] = "<oneOrMore>" stack[stack_i] "</oneOrMore>"
    if (length(line) >= 2)
      parse_pattern(substr(line, 2));
  }
  else if (c == "\"") {
    txt = substr(line, 2);
    sub(/".*/, "", txt)
    stack[++stack_i] = "<value>" txt "</value>";
    if (length(line) >= length(txt) + 3)
      parse_pattern(substr(line, length(txt) + 3));
  }
  else if (match(line, "^element ")) {
    aft = substr(line, 8);
    sub(/^ */, "", aft);
    name = aft;
    stack[++stack_i] = "<element";
    mode = "name_class";
    name_class_i = stack_i;
    parse_name_class(name);
  }
  else if (match(line, "^attribute ")) {
    aft = substr(line, 10);
    sub(/^ */, "", aft);
    name = aft;
    stack[++stack_i] = "<attribute";
    mode = "name_class";
    name_class_i = stack_i;
    parse_name_class(name);
  }
  else if (match(line, "^list ")) {
    aft = substr(line, 5);
    sub(/^ */, "", aft);
    stack[++stack_i] = "<list>";
    if (aft != "") { parse_pattern(aft); }
  }
  else if (match(line, "^mixed ")) {
    aft = substr(line, 6);
    sub(/^ */, "", aft);
    stack[++stack_i] = "<mixed>";
    if (aft != "") { parse_pattern(aft); }
  }
  else if (match(line, /^text[^A-Za-z]/) || match(line, /^text$/)) {
    stack[++stack_i] = "<text/>";
    aft = substr(line, 5);
    sub(/^ */, "", aft);
    if (aft != "") { parse_pattern(aft); }
  }
  else if (match(line, "^default namespace ")) {
    print "default namespace appeared out of context on line " FNR | "cat 1>&2";
    error = 1;
    exit 1
  }
  else if (match(line, "^namespace ")) {
    print "namespace appeared out of context on line " FNR | "cat 1>&2";
    error = 1;
    exit 1
  }
  else if (match(line, "^start ")) {
    print "start appeared out of context on line " FNR | "cat 1>&2";
    error = 1;
    exit 1
  }
  else if (match(line, /^xsd:[A-Za-z_]/)) {
    name = substr(line, 1);
    sub(/^xsd:/, "", name);
    sub(/[^A-Za-z_]+.*/, "", name);
    stack[++stack_i] = sprintf("<data type='%s' datatypeLibrary='http://www.w3.org/2001/XMLSchema-datatypes'/>",
                               name);
    if (length(line) >= length(name) + 5) {
      aft = substr(line, length(name) + 5);
      parse_pattern(aft);
    }
  }
  else if (match(line, /^[A-Za-z_]/)) {
    name = substr(line, 1);
    sub(/[^A-Za-z_]+.*/, "", name);
    stack[++stack_i] = sprintf("<ref name='%s'/>", name);
    if (length(line) >= length(name) + 1) {
      aft = substr(line, length(name) + 1);
      parse_pattern(aft);
    }
  }
}

function parse_name_class (line) {
  sub(/^ */, "", line)
  if (length(line) == 0) return;
  c = substr(line, 1, 1);
  if (c == "{") {
    if (stack_i != name_class_i) {
      tmp = "";
      for (i = stack_i; i >= name_class_i; i--) {
        if (stack[i] == "<except>") {
          tmp = "<except>" tmp "</except>";
        }
        else if (stack[i] == "<anyName>") {
          tmp = "<anyName>" tmp "</anyName>";
        }
        else {
          tmp = stack[i] tmp
        }
      }
      stack[name_class_i] = tmp;
      stack_i = name_class_i;
    }
    mode = "pattern";
    parse_pattern(line);
  }
  else if (c == "*") {
    if (stack[stack_i] == "<element" || stack[stack_i] == "<attribute") {
      stack[stack_i] = stack[stack_i] ">";
    }
    stack[++stack_i] = "<anyName>";
    parse_name_class(substr(line, 2));
  }
  else if (c == "-") {
    stack[++stack_i] = "<except>"
    parse_name_class(substr(line, 2));
  }
  else if (c == "|") {
    if (length(stack[paren[paren_i]]) == 1) {
      stack[paren[paren_i]] = stack[paren[paren_i]] c;
    }
    else if (substr(stack[paren[paren_i]], 2) != "|") {
      print "Mismatched infix operators on line " FNR | "cat 1>&2";
      error = 1;
      exit 1
    }
    parse_name_class(substr(line, 2));
  }
  else if (c == "(") {
    stack[++stack_i] = "(";
    paren[++paren_i] = stack_i;
    parse_name_class(substr(line, 2));
  }
  else if (c == ")") {
    open = stack[paren[paren_i]];
    if (substr(open, 1, 1) != "(") {
      print "Mismatched parentheses on line " FNR | "cat 1>&2";
      error = 1;
      exit 1
    }
    if (length(open) == 1 || substr(open, 2, 1) != "|") {
      print "Unknown name class pattern on line " FNR | "cat 1>&2";
      error = 1;
      exit 1
    }
    tmp = ""
    for (i = paren[paren_i] + 1; i <= stack_i; i++) {
      tmp = tmp stack[i] "\n";
    }
    stack_i = paren[paren_i];
    stack[stack_i] = tmp;
    paren_i--;
    parse_name_class(substr(line, 2));
  }
  else if (match(line, /^[A-Za-z_]/)) {
    name = substr(line, 1);
    sub(/[^A-Za-z_]+.*/, "", name);
    if (length(line) >= length(name) + 1)
      aft = substr(line, length(name) + 1);
    else
      aft = "";
    if (length(aft) >= 2 && substr(aft, 1, 2) == ":*") {
      for (i = 1; i <= namespaces_i; i++) {
        if (nsnames[i] == name) {
          stack[++stack_i] = sprintf("<nsName ns='%s'/>", namespaces[i])
          break;
        }
      }
      if (length(aft) >= 3)
        aft = substr(aft, 3);
      else
        aft = "";
    }
    else {
      if (length(aft) >= 2 && substr(aft, 1, 1) == ":") {
        checkns = "";
        pos = 1;
        while (pos <= namespaces_i) {
          if (namespaces[pos] != "" && nsnames[pos] == name) {
            checkns = namespaces[pos];
            break;
          }
          pos++;
        }
        if (checkns == "") {
          print "Unknown namespace prefix " name " on line " FNR | "cat 1>&2";
          error = 1;
          exit 1
        }
        localname = substr(aft, 2);
        sub(/[^A-Za-z_]+.*/, "", localname);
        if (length(aft) >= length(localname) + 2)
          aft = substr(aft, length(localname) + 2);
        else
          aft = "";
        name = name ":" localname;
      }
      if (stack[stack_i] == "<element" || stack[stack_i] == "<attribute") {
        stack[stack_i] = stack[stack_i] sprintf(" name='%s'>", name);
      }
      else {
        stack[++stack_i] = sprintf("<name>%s</name>", name);
      }
    }
    parse_name_class(aft);
  }
}

function printstack () {
  pos = 1;
  while (pos <= stack_i) {
    printstackone();
  }
}
function printstackone () {
  if (substr(stack[pos], 1, 6) == "<start") {
    print stack[pos];
    pos++;
    printstackone();
    print "</start>"
  }
  else if (substr(stack[pos], 1, 7) == "<define") {
    print stack[pos];
    pos++;
    printstackone();
    print "</define>"
  }
  else {
    print stack[pos];
    pos++;
  }
}

BEGIN {
  mode = "grammar";
  stack_i = 0;
  paren_i = 0;
  namespaces_i = 0;
  error = 0;
}

END {
  if (!error) {
    print "<grammar xmlns='http://relaxng.org/ns/structure/1.0'";
    pos = 1;
    while (pos <= namespaces_i) {
      if (namespaces[pos] != "") {
        printf " xmlns:%s='%s'", nsnames[pos], namespaces[pos];
      }
      pos++;
    }
    printf " ns='%s'>\n", default_namespace;
    printstack()
    print "</grammar>"
  }
}

mode == "pattern" && paren_i == 0 && /.*=/ { mode = "grammar"; }
mode == "grammar" && /.*=/ {
  if (match($0, "^default namespace ")) {
    namespace = substr($0, index($0, "=") + 1);
    nsname = substr($0, 19, index($0, "=") - 19);
    sub(/^ */, "", nsname);
    sub(/ *$/, "", nsname);
    sub(/^ *"/, "", namespace);
    sub(/" *$/, "", namespace);
    if (nsname != "") {
      nsnames[++namespaces_i] = nsname;
      namespaces[namespaces_i] = namespace;
    }
    default_namespace = namespace
  }
  else if (match($0, "^namespace ")) {
    namespace = substr($0, index($0, "=") + 1);
    nsname = substr($0, 11, index($0, "=") - 11);
    sub(/^ */, "", nsname);
    sub(/ *$/, "", nsname);
    sub(/^ *"/, "", namespace);
    sub(/" *$/, "", namespace);
    if (nsname != "") {
      nsnames[++namespaces_i] = nsname;
      namespaces[namespaces_i] = namespace;
    }
  }
  else {
    nameix = index($0, "=");
    combine = "";
    if (nameix < 1) next;
    if (substr($0, nameix - 1, 1) == "|") {
      combine = "choice";
      name = substr($0, 1, nameix - 2);
    }
    else if (substr($0, nameix - 1, 1) == "&") {
      combine = "interleave";
      name = substr($0, 1, nameix - 2);
    }
    else {
      name = substr($0, 1, nameix - 1);
    }
    sub(/ /, "", name);
    if (name == "start")
      stack[++stack_i] = "<start>"
    else {
      define = sprintf("<define name='%s'", name);
      if (combine != "")
        define = define " combine='" combine "'"
      define = define ">"
      stack[++stack_i] = define;
    }
    mode = "pattern";
    if (length($0) >= nameix + 1)
      parse_pattern(substr($0, nameix + 1))
  }
  next;
}
mode == "pattern" {
  parse_pattern($0);
  next;
}
mode == "name_class" {
  parse_name_class($0);
  next;
}


hr75: #i116747#: remove obsolete copyright notices

#*************************************************************************
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# Copyright 2000, 2010 Oracle and/or its affiliates.
#
# OpenOffice.org - a multi-platform office productivity suite
#
# This file is part of OpenOffice.org.
#
# OpenOffice.org is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# only, as published by the Free Software Foundation.
#
# OpenOffice.org is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License version 3 for more details
# (a copy is included in the LICENSE file that accompanied this code).
#
# You should have received a copy of the GNU Lesser General Public License
# version 3 along with OpenOffice.org.  If not, see
# <http://www.openoffice.org/license.html>
# for a copy of the LGPLv3 License.
#
#*************************************************************************

#
# Dieses awk-script generiert ein cxx-file, das alle PoolIds der Vorlage dumpt.
# wird fuer den HelpPI gebraucht.
# Aufruf:  awk -f poolid.awk poolfmt.hxx > poolid.cxx
#          cl poolid.cxx
#          poolid.exe > ???.hrc
#

function Header() {
    print "// This is an outputfile of an awk-script: $Workfile:   poolfmt.awk  $"
    print "#include <solar.h> "
    print
    print  "#include <stdio.h>"
    print  "#include <stdlib.h>"
    print
    print  "#pragma hdrstop"
    print
    print "#include <iostream.hxx> "
    print "#include \"poolfmt.hxx\""
    print
}

function Main() {
	print
    print  "void main( int , char *[] ) {"
    sStr = "#define"
    print  "    int nSize = (sizeof(ppPoolIds) / sizeof(PoolFmtIds)) - 1;"
    print  "    for( int n = 0; n < nSize; n++ )"
    print  "        printf( \"" sStr " %s\\t%8d\\n\", ppPoolIds[ n ].pStr, ppPoolIds[ n ].nId );"
    print  "}"
}

function TableHead() {
	print
    print "struct PoolFmtIds { int nId; const char* pStr; };"
    print "static PoolFmtIds ppPoolIds[] = {"
}

function TableTail() {
    print  " 0, \"\" };"
    print
}

BEGIN {
    Header();
    TableHead();
}

/^[ \t]*RES_/ && !index( $1, "_BEGIN" ) && !index( $1, "_END" ) && !index( $1, "_POOL_" ) {
    sStr = $1;
	split( $1, sStr, "," );
    print  "    " sStr[1] ", \"" sStr[1] "\","
}

END {
    TableTail();
    Main();
}

#*************************************************************************
#*
#*    $Workfile:        dbgxtor.awk
#*
#*    Ersterstellung    JP  05.10.95
#*    Letzte Aenderung  $Author: hr $ $Date: 2000-09-18 17:14:27 $
#*    $Revision: 1.1.1.1 $
#*
#*    $Logfile:   T:/sw/inc/poolfmt.awv  $
#*
#*    Copyright (c) 1990-1996, STAR DIVISION
#*
#*************************************************************************

#
# Dieses awk-script generiert ein cxx-file, das alle PoolIds der Vorlage dumpt.
# wird fuer den HelpPI gebraucht.
# Aufruf:  awk -f poolid.awk poolfmt.hxx > poolid.cxx
#          cl poolid.cxx
#          poolid.exe > ???.hrc
#

function Header() {
    print "// This is an outputfile of an awk-script: $Workfile:   poolfmt.awk  $"
    print "#include <solar.h> "
    print
    print  "#include <stdio.h>"
    print  "#include <stdlib.h>"
    print
    print  "#pragma hdrstop"
    print
    print "#include <iostream.hxx> "
    print "#include \"poolfmt.hxx\""
    print
}

function Main() {
	print
    print  "void main( int , char *[] ) {"
    sStr = "#define"
    print  "    int nSize = (sizeof(ppPoolIds) / sizeof(PoolFmtIds)) - 1;"
    print  "    for( int n = 0; n < nSize; n++ )"
    print  "        printf( \"" sStr " %s\\t%8d\\n\", ppPoolIds[ n ].pStr, ppPoolIds[ n ].nId );"
    print  "}"
}

function TableHead() {
	print
    print "struct PoolFmtIds { int nId; const char* pStr; };"
    print "static PoolFmtIds ppPoolIds[] = {"
}

function TableTail() {
    print  " 0, \"\" };"
    print
}

BEGIN {
    Header();
    TableHead();
}

/^[ \t]*RES_/ && !index( $1, "_BEGIN" ) && !index( $1, "_END" ) && !index( $1, "_POOL_" ) {
    sStr = $1;
	split( $1, sStr, "," );
    print  "    " sStr[1] ", \"" sStr[1] "\","
}

END {
    TableTail();
    Main();
}


Commons: add escapeChar()

Commons: add escapeChar()

#!/usr/bin/gawk -f

# Return the real character represented by an escape sequence.
# Example: escapeChar("n") returns "\n".
# See: <https://en.wikipedia.org/wiki/Escape_character>
#      <https://en.wikipedia.org/wiki/Escape_sequences_in_C>
function escapeChar(char) {
    switch (char) {
    case "b":
        return "\b" # Backspace
    case "f":
        return "\f" # Formfeed
    case "n":
        return "\n" # Newline (Line Feed)
    case "r":
        return "\r" # Carriage Return
    case "t":
        return "\t" # Horizontal Tab
    case "v":
        return "\v" # Vertical Tab
    default:
        return char
    }
}

# Convert a literal-formatted string into its original string.
function literal(string,
                 ####
                 c, escaping, i, s) {
    if (string !~ /^".*"$/)
        return string

    split(string, s, "")
    string = ""
    escaping = 0
    for (i = 2; i < length(s); i++) {
        c = s[i]
        if (escaping) {
            string = string escapeChar(c)
            escaping = 0 # escape ends
        } else {
            if (c == "\\")
                escaping = 1 # escape begins
            else
                string = string c
        }
    }
    return string
}

# Append an element into an array (zero-based).
function append(array, element) {
    array[length(array)] = element
}

# Return 1 if the array contains anything; otherwise return 0.
function anything(array,
                  ####
                  i) {
    for (i in array)
        if (array[i]) return 1
    return 0
}

# Return an element if it belongs to the array;
# Otherwise, return a null string.
function belongsTo(element, array,
                   ####
                   i) {
    for (i in array)
        if (element == array[i]) return element
    return ""
}

# Return one of the substrings if the string starts with it;
# Otherwise, return a null string.
function startsWithAny(string, substrings,
                       ####
                       i) {
    for (i in substrings)
        if (index(string, substrings[i]) == 1) return substrings[i]
    return ""
}

# Return one of the patterns if the string matches this pattern at the beginning;
# Otherwise, return a null string.
function matchesAny(string, patterns,
                    ####
                    i) {
    for (i in patterns)
        if (string ~ "^" patterns[i]) return patterns[i]
    return ""
}

# Join an array into one string;
# Return the string.
function join(array, separator, sortedIn,
              ####
              i, j, saveSortedIn, temp) {
    # Default parameters
    if (!separator)
        separator = " "
    if (!sortedIn)
        sortedIn = "@ind_num_asc"

    temp = ""
    j = 0
    saveSortedIn = PROCINFO["sorted_in"]
    PROCINFO["sorted_in"] = sortedIn
    for (i in array)
        temp = j++ ? temp separator array[i] : array[i]
    PROCINFO["sorted_in"] = saveSortedIn

    return temp
}

# Debug an array.
function da(array, formatString, sortedIn,
                ####
                i, j, saveSortedIn) {
    # Default parameters
    if (!formatString)
        formatString = "_[%s]='%s'"
    if (!sortedIn)
        sortedIn = "@ind_num_asc"

    saveSortedIn = PROCINFO["sorted_in"]
    PROCINFO["sorted_in"] = sortedIn
    for (i in array) {
        split(i, j, SUBSEP)
        d(sprintf(formatString, join(j, ","), array[i]))
    }
    PROCINFO["sorted_in"] = saveSortedIn
}

#!/usr/bin/gawk -f

# Convert a literal-formatted string into its original string.
function literal(string,
                 ####
                 c, escaping, i, s) {
    if (string !~ /^".*"$/)
        return string

    split(string, s, "")
    string = ""
    escaping = 0
    for (i = 2; i < length(s); i++) {
        c = s[i]
        if (escaping) {
            string = string c
            escaping = 0 # escape ends
        } else {
            if (c == "\\")
                escaping = 1 # escape begins
            else
                string = string c
        }
    }
    return string
}

# Append an element into an array (zero-based).
function append(array, element) {
    array[length(array)] = element
}

# Return 1 if the array contains anything; otherwise return 0.
function anything(array,
                  ####
                  i) {
    for (i in array)
        if (array[i]) return 1
    return 0
}

# Return an element if it belongs to the array;
# Otherwise, return a null string.
function belongsTo(element, array,
                   ####
                   i) {
    for (i in array)
        if (element == array[i]) return element
    return ""
}

# Return one of the substrings if the string starts with it;
# Otherwise, return a null string.
function startsWithAny(string, substrings,
                       ####
                       i) {
    for (i in substrings)
        if (index(string, substrings[i]) == 1) return substrings[i]
    return ""
}

# Return one of the patterns if the string matches this pattern at the beginning;
# Otherwise, return a null string.
function matchesAny(string, patterns,
                    ####
                    i) {
    for (i in patterns)
        if (string ~ "^" patterns[i]) return patterns[i]
    return ""
}

# Join an array into one string;
# Return the string.
function join(array, separator, sortedIn,
              ####
              i, j, saveSortedIn, temp) {
    # Default parameters
    if (!separator)
        separator = " "
    if (!sortedIn)
        sortedIn = "@ind_num_asc"

    temp = ""
    j = 0
    saveSortedIn = PROCINFO["sorted_in"]
    PROCINFO["sorted_in"] = sortedIn
    for (i in array)
        temp = j++ ? temp separator array[i] : array[i]
    PROCINFO["sorted_in"] = saveSortedIn

    return temp
}

# Debug an array.
function da(array, formatString, sortedIn,
                ####
                i, j, saveSortedIn) {
    # Default parameters
    if (!formatString)
        formatString = "_[%s]='%s'"
    if (!sortedIn)
        sortedIn = "@ind_num_asc"

    saveSortedIn = PROCINFO["sorted_in"]
    PROCINFO["sorted_in"] = sortedIn
    for (i in array) {
        split(i, j, SUBSEP)
        d(sprintf(formatString, join(j, ","), array[i]))
    }
    PROCINFO["sorted_in"] = saveSortedIn
}


Fixed some things in wrap.awk: - GitHub-style code blocks are now supported. - Lists starting with '-' characters were confused with headers - Footnotes are passed through verbatim - Forced linebreaks (spaces at EOL) work now

# Like the Un*x `fmt` command, but for markdown.
#
# It does its best to preserve markdown headings,
# lists, pre-formatted code blocks and block quotes.

BEGIN { if(!Width) Width = 80; }

# Preserve headings
/^[[:space:]]*[=\-][=\-][=\-]+/ {
    if(Buf)
        Out = Out Buf "\n" $0 "\n";
    else
        Out = Out $0 "\n";
    Buf = "";
    next;
}

# Preformatted text is sent to the output verbatim
# Ditto for links/abbreviations
/^(    |\t)+/ && match(last,/^[[:space:]]*$/) || /^[[:space:]]*\*?\[.*\]:/ {
    Out = Out $0 "\n";
    next;
}

# GitHub-style ``` code blocks:
/^```/ {
    Out = Out Buf "\n" $0 "\n";
    Buf = "";
    Code = !Code;
    next;
}
Code {
    Out = Out $0 "\n";
    next;
}

$0 !~ /^[[:space:]]*$/ && match(last,/^[[:space:]]*$/) {
    # how much is the current line indented
    match(str, /^[[:space:]]+/);
    Indent = substr(str, 1, RLENGTH);
}

# Blank lines cause blank lines in the output
/^[[:space:]]*$/ {
    # You need to preserve $0 for blank lines in preformatted blocks
    if(Buf)
        Out = Out Buf "\n" $0 "\n";
    else
        Out = Out "\n" $0;
    Buf = "";
    last = $0;
    InList = 0;
    next;
}

# Handle every other input line
{ last = $0; fmt($0); }

# Write output when done
END {
    Out = Out Buf;
    print Out;
}

function fmt(str,          loc,word,n,indent) {

    # Get the current line's indentation level.
    match(str, /^[[:space:]]+/);
    indent = substr(str, 1, RLENGTH);

    # Trim leading whitespace
    str = substr(str, RLENGTH+1);
    gsub(/\r/, "", str); # Windows :(

    # Lines starting with list item characters
    # force a line break in the output
    if(match(str,/^([*+\-]|[[:digit:]]+\.)/)) {
        if(Buf) Out = Out Buf "\n";
        Buf = "";
        # Preserve the indentation in the global Indent
        # if it is a list that is going to be split.
        Indent = indent;
        InList = 1; # remember we're in a list on subsequent calls.
    } else if(match(str,/^>[[:space:]]+/)) {
        Indent = indent substr(str, 1, RLENGTH);
        str = substr(str,RLENGTH+1);
    }

    # Current indentation level = global Indent
    indent = Indent;

    # This implements the simple algorithm from the wikipedia
    # https://en.wikipedia.org/wiki/Line_wrap_and_word_wrap
    # There is a better way. See #Minimum_raggedness on that wiki page.
    # The C code example on https://www.rosettacode.org/wiki/Word_wrap#C
    # may actually be easy to port to Awk (the Awk version on that page
    # implements the greedy algorithm, like I do here).

    loc = match(str, /[[:space:]]+/);
    while(loc) {
        word = substr(str, 1, RSTART-1);
        n = RSTART+RLENGTH;

        # Handle forced line breaks
        if(match(str,/(  |[[:space:]]+\\)$/) == loc) {
            if(length(Buf) + length(str) + 1 >= Width)
                Out = Out Buf "\n" indent str "\n" indent;
            else
                Out = Out Buf " " str "\n" indent;
            Buf = "";
            return;
        }

        # If the buffer + the word exceeds the allowed width
        # then insert a line break. Otherwise, just append the
        # word to the buffer.
        # Also, preserve the indentation.
        if(length(Buf) + length(word) + 1 >= Width) {
            Out = Out Buf "\n";
            if(InList) indent = Indent "  ";
            Buf = indent word;
        } else if(length(Buf))
            Buf = Buf " " word;
        else
            Buf = indent word;

        str = substr(str, n);
        loc = match(str, /[[:space:]]+/);
    }

    # Append the remainder of str to Buf
    if(length(str)) {
        if(length(Buf) + length(str) + 1 >= Width) {
            Out = Out Buf "\n";
            if(InList) indent = Indent "  ";
            Buf = indent str;
        } else if(length(Buf))
            Buf = Buf " " str;
        else
            Buf = indent str;
    }
}

# Like the Un*x `fmt` command, but for markdown.
#
# It does its best to preserve markdown headings,
# lists, pre-formatted code blocks and block quotes.

BEGIN { if(!Width) Width = 80; }

# Preserve headings
/^[[:space:]]*(=|-)+/ {
    if(Buf)
        Out = Out Buf "\n" $0 "\n";
    else
        Out = Out $0 "\n";
    Buf = "";
    next;
}

# Preformatted text is sent to the output verbatim
/^(    |\t)+/ && match(last,/^[[:space:]]*$/) {
    Out = Out $0 "\n";
    next;
}

$0 !~ /^[[:space:]]*$/ && match(last,/^[[:space:]]*$/) {
    # how much is the current line indented
    match(str, /^[[:space:]]+/);
    Indent = substr(str, 1, RLENGTH);
}

# Blank lines cause blank lines in the output
/^[[:space:]]*$/ {
    # You need to preserve $0 for blank lines in preformatted blocks
    if(Buf)
        Out = Out Buf "\n" $0 "\n";
    else
        Out = Out "\n" $0;
    Buf = "";
    last = $0;
    InList = 0;
    next;
}

# Handle every other input line
{ last = $0; fmt($0); }

# Write output when done
END {
    Out = Out Buf;
    print Out;
}

function fmt(str,          loc,word,n,indent) {

    # Get the current line's indentation level.
    match(str, /^[[:space:]]+/);
    indent = substr(str, 1, RLENGTH);

    # Trim leading whitespace
    str = substr(str, RLENGTH+1);

    # Lines starting with list item characters
    # force a line break in the output
    if(match(str,/^([*+-]|[[:digit:]]\.)/)) {
        if(Buf) Out = Out Buf "\n";
        Buf = "";
        # Preserve the indentation in the global Indent
        # if it is a list that is going to be split.
        Indent = indent;
        InList = 1; # remember we're in a list on subsequent calls.
    } else if(match(str,/^>[[:space:]]+/)) {
        Indent = indent substr(str, 1, RLENGTH);
        str = substr(str,RLENGTH+1);
    }

    # Current indentation level = global Indent
    indent = Indent;

    # This implements the simple algorithm from the wikipedia
    # https://en.wikipedia.org/wiki/Line_wrap_and_word_wrap
    # There is a better way. See #Minimum_raggedness on that wiki page.
    # The C code example on https://www.rosettacode.org/wiki/Word_wrap#C
    # may actually be easy to port to Awk (the Awk version on that page
    # implements the greedy algorithm, like I do here).

    loc = match(str, /[[:space:]]+/);
    while(loc) {
        word = substr(str, 1, RSTART-1);
        n = RSTART+RLENGTH;

        # Handle forced line breaks
        if(match(str,/(  |[[:space:]]+\\)$/)) {
            Out = Out str "\n";
            n = RSTART+RLENGTH;
        } else {
            # If the buffer + the word exceeds the allowed width
            # then insert a line break. Otherwise, just append the
            # word to the buffer.
            # Also, preserve the indentation.
            if(length(Buf) + length(word) + 1 >= Width) {
                Out = Out Buf "\n";
                if(InList) indent = Indent "  ";
                Buf = indent word;
            } else if(length(Buf))
                Buf = Buf " " word;
            else
                Buf = indent word;
        }
        str = substr(str, n);
        loc = match(str, /[[:space:]]+/);
    }

    # Append the remainder of str to Buf
    if(length(str)) {
        if(length(Buf) + length(str) + 1 >= Width) {
            Out = Out Buf "\n";
            if(InList) indent = Indent "  ";
            Buf = indent str;
        } else if(length(Buf))
            Buf = Buf " " str;
        else
            Buf = indent str;
    }
}


TestLanguages: fix test

TestLanguages: fix test

@include "include/Languages"

BEGIN {
    START_TEST("Languages.awk")

    T("getCode()", 5)
    {
        initLocale()
        initLocaleAlias()
        initLocaleDisplay()

        assertEqual(getCode("chinese"), "zh-CN")
        assertEqual(getCode("简体中文"), "zh-CN")
        assertEqual(getCode("正體中文"), "zh-TW")
        assertEqual(getCode("Japanese"), "ja")
        assertEqual(getCode("日本語"), "ja")
    }

    END_TEST()
}

@include "include/Languages"

BEGIN {
    START_TEST("Languages.awk")

    T("getCode()", 5)
    {
        initLocale()

        assertEqual(getCode("chinese"), "zh-CN")
        assertEqual(getCode("简体中文"), "zh-CN")
        assertEqual(getCode("正體中文"), "zh-TW")
        assertEqual(getCode("Japanese"), "ja")
        assertEqual(getCode("日本語"), "ja")
    }

    END_TEST()
}


prints output on only one node now for util_version.F

#
# This script is used by the makefile in building util_version.f.
# It expects on standard input lines containing
#
# a CVS ID    -> produce a write statement with the ID
# module name -> produce a write statement for the module name
# other       -> produce nothing
#
# $Id: ids.awk,v 1.4 1997-07-15 19:52:52 d3e129 Exp $

BEGIN {
		underline = "---------------------------------------------------------";
		printf("      subroutine util_version\n");
                printf("#include \"global.fh\"\n");
                printf("      if (ga_nodeid().eq.0) then\n");
		printf("      write(6,*)\n");
		printf("      write(6,*) ' Software version information'\n");
		printf("      write(6,*) ' ----------------------------'\n");
}

/^module/			{
				 len = length($0);
				 printf("      write(6,*)\n");
				 printf("      write(6,*) ' %s'\n",$0);
				 printf("      write(6,*) ' %s'\n",substr(underline,1,len));
				}

/\$\I\d: [^\n]*Exp \$/		{
				 i = index($0, "$Id: ") + 5;
				 j = index($0, "Exp $") - 1;
				 n = j - i + 1;
				 if (n > (72 - 20)) n = 72 - 20;
				 printf("      write(6,*) ' %s'\n",substr($0,i,n));
				}

END {
		printf("      write(6,*)\n");
		printf("      call util_flush(6)\n");
                printf("      endif\n");
                printf("      call ga_sync()\n");
		printf("      end\n");
}

#
# This script is used by the makefile in building util_version.f.
# It expects on standard input lines containing
#
# a CVS ID    -> produce a write statement with the ID
# module name -> produce a write statement for the module name
# other       -> produce nothing
#
# $Id: ids.awk,v 1.3 1995-02-02 20:21:59 d3g681 Exp $

BEGIN {
		underline = "---------------------------------------------------------";
		printf("      subroutine util_version\n");
		printf("      write(6,*)\n");
		printf("      write(6,*) ' Software version information'\n");
		printf("      write(6,*) ' ----------------------------'\n");
}

/^module/			{
				 len = length($0);
				 printf("      write(6,*)\n");
				 printf("      write(6,*) ' %s'\n",$0);
				 printf("      write(6,*) ' %s'\n",substr(underline,1,len));
				}

/\$\I\d: [^\n]*Exp \$/		{
				 i = index($0, "$Id: ") + 5;
				 j = index($0, "Exp $") - 1;
				 n = j - i + 1;
				 if (n > (72 - 20)) n = 72 - 20;
				 printf("      write(6,*) ' %s'\n",substr($0,i,n));
				}

END {
		printf("      write(6,*)\n");
		printf("      call util_flush(6)\n");
		printf("      end\n");
}


remove unused file

remove unused file

BEGIN {IGNORECASE=1}
!/^(abdominal N:|aberrant N:|abnormal N:|absurd N:|acoustic N:|\
actual N:|after N|acupuncture V:|adipose N:|adulterate A:|adz V:|\
adze V:|aesthetic N:|afar N:|afferent N:|affiance N:|affluent N:|\
affray V:|aforethought N:|ageing N:|agent V:|airfreight V:|alligator V:|\
allover N:|allowance V:|alpha A:|altogether N:|aluminum A:|ambient N:|\
ambition V:|amen N:|amok N:|amuck N:|anagram V:|angel V:|anneal N:|\
antedate N:|antediluvian N:|anthem V:|antiaircraft N:|antidote V:|\
antimalarial N:|antimicrobial N:|antimissile N:|antislavery N:|apical N:|\
apoplectic N:|appurtenant N:|apron V:|arable N:|arbitrary N:|arcade V:|\
architect V:|armorial N:|arrow V:|arterial N:|article V:|aseptic N:|ashlar V:|\
aspen A:|asphalt A:|asteroid A:|astigmatic N:|auctioneer V:|audiovisual N:|\
auditory N:|augment N:|augmentative N:|auricular N:|austral N:|autoclave V:|\
avalanche V:|awol N:|backdrop V:|backgammon V:|background V:|backlash V:|\
backwash V:|badge V:|badinage V:|bagpipe V:|bailout A:|baize V:|baksheesh V:|\
bandy N:|bard V:|barn V:|basset V:|baste N:|bate N:|bath V:|batik V:|\
battledore V:|bawdy N:|beacon V:|beau V:|beck V:|beckon N:|beeswax V:|\
beg N:|begum V:|belay N:|benchmark V:|benefice V:|berserk N:|between N:|\
bib V:|big V:|bight V:|bilge V:|bilk N:|billboard V:|biologic N:|biological N:|\
birdlime V:|bishop V:|bit V:|bitter V:|bivalent N:|blabber N:|blackbird V:|\
blackguard V:|bleak N:|blear V:|bleed N:|blinding N:|blip V:|blitzkrieg V:|\
bloat N:|blubber A:|blurb V:|bobtail A:|bobtail V:|body V:|boldface V:|\
bolt A:|bombard N:|bond A:|bone A:|bonnet V:|bonnie N:|bonny N:|\
boodle V:|boring N:|bosom V:|bossy N:|botanical N:|bottleneck V:|\
bowel V:|bower V:|bowstring V:|bracing N:|brad V:|brag A:|braille V:|\
bramble V:|bran V:|brander V:|brandish N:|brash N:|brassy N:|bravo V:|\
breadboard V:|bream V:|breech V:|brigade V:|brine V:|briny N:|briquet V:|\
briquette V:|brittle V:|broom V:|bruit N:|brute V:|buckler V:|buckram V:|\
buddy A:|buddy V:|budge N:|bullet V:|bulwark V:|bumble N:|bumper V:|\
bung A:|bunker V:|bunko V:|bur V:|burgeon N:|burl V:|but A:|burning N:|\
bush A:|byline V:|cabal V:|cabbage V:|cabin V:|cadence V:|cadge N:|\
cakewalk V:|caller A:|callow N:|caloric N:|cam V:|came N:|canal V:|\
canary A:|cancel N:|candid N:|candidate V:|cannonball A:|cant A:|\
canton V:|cape V:|car A:|caravan V:|carcass V:|\
cardiac N:|\
careen N:|\
carhop V:|\
carny A:|\
carny V:|\
carton V:|\
cask V:|\
casket V:|\
castrate N:|\
cat V:|\
catchpenny N:|\
cathedral A:|\
catty N:|\
causative N:|\
causeway V:|\
cavalier V:|\
cavern V:|\
celestial N:|\
cellar V:|\
centrifugal N:|\
cerebral N:|\
chafe N:|\
chairman V:|\
chamber V:|\
chammy V:|\
chamois V:|\
chapel V:|\
chapter V:|\
character V:|\
charcoal V:|\
chariot V:|\
chartreuse A:|\
cheap N:|\
checkerboard V:|\
chicane V:|\
chimney V:|\
chine V:|\
chipper V:|\
choir V:|\
chord V:|\
choroid A:|\
chose N:|\
chump V:|\
chunk V:|\
church V:|\
chute V:|\
cincture V:|\
circumflex A:|\
circumflex V:|\
clad V:|\
clangor V:|\
clangour V:|\
clay V:|\
cleat V:|\
clerical N:|\
clinker V:|\
clique V:|\
closure V:|\
cloture V:|\
cnidarian A:|\
coagulate A:|\
cobweb V:|\
cockfighting A:|\
cockle V:|\
cocktail V:|\
cocky N:|\
coelenterate A:|\
coffeehouse V:|\
coffer V:|\
cog V:|\
collage V:|\
collegiate N:|\
colloid A:|\
columbine A:|\
commemorative N:|\
commie A:|\
communicant A:|\
companion V:|\
company V:|\
compartment V:|\
compassion V:|\
compassionate V:|\
compeer V:|\
complementary N:|\
complex V:|\
complicate A:|\
composite V:|\
compulsive N:|\
compute N:|\
concave V:|\
conceit V:|\
concessionary N:|\
concurrent N:|\
cone V:|\
confection V:|\
conference V:|\
confident N:|\
confiscate A:|\
confluent N:|\
congregate A:|\
congress V:|\
conjugate N:|\
consecrate A:|\
consequent N:|\
conservatory A:|\
considerable N:|\
constabulary A:|\
construe N:|\
contaminate A:|\
contradictory N:|\
contralto A:|\
contributory N:|\
convict A:|\
copper V:|\
corbel V:|\
corduroy V:|\
cornice V:|\
corroborate A:|\
corrugate A:|\
cosset N:|\
cosy V:|\
cote V:|\
cotter V:|\
counterpoint V:|\
counterweight V:|\
coup V:|\
courtesy V:|\
cove V:|\
cowhide V:|\
cowl V:|\
coy V:|\
cozy V:|\
cram N:|\
crape V:|\
craven V:|\
crawfish V:|\
credential A:|\
credential V:|\
crenelate A:|\
crenellate A:|\
crepe V:|\
crescendo V:|\
crevasse V:|\
cricket V:|\
crock V:|\
croquet V:|\
crossbred N:|\
crosshatch N:|\
crosstown N:|\
crowbar V:|\
crowning N:|\
crud V:|\
crummy N:|\
crutch V:|\
crystal V:|\
cub V:|\
cubic N:|\
cuckoo V:|\
cumber N:|\
curd V:|\
custodial N:|\
customary N:|\
cyanide V:|\
cyclical N:|\
cylinder V:|\
cynic A:|\
dado V:|\
dagger V:|\
damndest N:|\
damnedest N:|\
dangle N:|\
dark V:|\
dastard A:|\
daylight V:|\
deacon V:|\
deafening N:|\
deal A:|\
debouch N:|\
decal V:|\
decision V:|\
dedicate A:|\
defence V:|\
defendant A:|\
deficient N:|\
definitive N:|\
defoliate A:|\
deject A:|\
delectable N:|\
delicate N:|\
demagog V:|\
demagogue V:|\
demolition A:|\
demoniac N:|\
demotic N:|\
den V:|\
denizen V:|\
dental N:|\
deponent A:|\
derail N:|\
derogate A:|\
derrick V:|\
descant A:|\
desiccant A:|\
desirable N:|\
desperate N:|\
despite N:|\
despite V:|\
destitute V:|\
determinate V:|\
detrimental N:|\
dew V:|\
diadem V:|\
diagnostic N:|\
dialog V:|\
dialogue V:|\
diamond V:|\
diaphragm V:|\
dick V:|\
dicker N:|\
dickey A:|\
difference V:|\
digestive N:|\
digital N:|\
dike V:|\
dimension V:|\
dingdong A:|\
dint V:|\
diphthong V:|\
diploma V:|\
directory A:|\
dirigible A:|\
dirk V:|\
disagreeable N:|\
disc V:|\
disciple V:|\
discomfit N:|\
discountenance N:|\
discriminate A:|\
disease V:|\
disinterest V:|\
disjoint A:|\
disjunctive N:|\
disk V:|\
dismal N:|\
disperse A:|\
displeasure V:|\
disport N:|\
dispose N:|\
disproportion V:|\
disquiet A:|\
dissolve N:|\
distaste V:|\
distemper V:|\
distributive N:|\
district V:|\
ditty V:|\
diurnal N:|\
dolly V:|\
douse N:|\
downcast N:|\
downstage N:|\
dowse N:|\
dozen V:|\
drab V:|\
dram V:|\
drat V:|\
dray V:|\
dreadful N:|\
drench N:|\
drinkable N:|\
droll V:|\
drove V:|\
drub N:|\
druggie A:|\
druggy A:|\
dual N:|\
duct V:|\
duet V:|\
duff V:|\
dug N:|\
dulcet N:|\
dummy V:|\
duodecimal N:|\
duplex V:|\
durable N:|\
dusk A:|\
dusk V:|\
dwell N:|\
dyke V:|\
eager N:|\
eagle V:|\
ear V:|\
early N:|\
earwig V:|\
eastward N:|\
echelon V:|\
ecstatic N:|\
effective N:|\
effeminate V:|\
efferent N:|\
effuse A:|\
eggshell A:|\
egress V:|\
ejaculate N:|\
elderly N:|\
electric N:|\
electroplate N:|\
electroshock V:|\
electrotype V:|\
elemental N:|\
elevated N:|\
elfin N:|\
eligible N:|\
elliptical N:|\
elongate A:|\
emasculate A:|\
emblem V:|\
embryo A:|\
emergency A:|\
emergent N:|\
emerita N:|\
emeritus N:|\
emphatic N:|\
empiric N:|\
enclave V:|\
enervate A:|\
ensilage V:|\
entail N:|\
entire N:|\
ephemera N|\
ephemeral N:|\
epitaph V:|\
equatorial N:|\
equinoctial N:|\
equipoise V:|\
erotic N:|\
eruptive N:|\
escrow V:|\
esquire V:|\
estate V:|\
esthetic N:|\
eternal N:|\
ethylene A:|\
eviscerate A:|\
ex A:|\
exasperate A:|\
excess V:|\
excommunicate A:|\
excommunicate N:|\
excursion V:|\
exempt N:|\
existent N:|\
expectant N:|\
expedite A:|\
expense V:|\
expert V:|\
expertise V:|\
expletive A:|\
exponential N:|\
exquisite N:|\
extravert A:|\
extravert V:|\
extrovert V:|\
eyelet V:|\
fable V:|\
facelift V:|\
faerie A:|\
faery A:|\
fair V:|\
fame V:|\
fang V:|\
fantastic N:|\
farce V:|\
farrow A:|\
fashionable N:|\
fat V:|\
fatigue A:|\
feat A:|\
fee V:|\
fellow V:|\
fellowship V:|\
felon A:|\
ferrule V:|\
ferule V:|\
fess N:|\
fetch N:|\
fettle V:|\
fever V:|\
fiberglass V:|\
fibroid N:|\
fife V:|\
filthy V:|\
fin V:|\
financier V:|\
finite N:|\
fishtail N:|\
fission V:|\
fissionable N:|\
fissure V:|\
fist V:|\
flack V:|\
flagellate N:|\
flagging N:|\
flamboyant N:|\
flange V:|\
flew N:|\
flight V:|\
flimsy N:|\
flint V:|\
floral N:|\
flume V:|\
fluorescent N:|\
fluoroscope V:|\
fodder V:|\
foldaway N:|\
folio A:|\
folio V:|\
follow N:|\
fond N:|\
fondu A:|\
football V:|\
forelock V:|\
forklift V:|\
formative N:|\
forthright N:|\
fortissimo N:|\
fortnightly N:|\
fortune V:|\
found N:|\
foursquare N:|\
fraction V:|\
frail N:|\
frappe V:|\
fraught N:|\
freewheel N:|\
frenetic N:|\
frenzy V:|\
fresco V:|\
fresh N:|\
fresh V:|\
freshman A:|\
friend V:|\
frill V:|\
frisk N:|\
fro N:|\
frock V:|\
frog V:|\
frolic A:|\
frontal N:|\
frosted N:|\
frustrate A:|\
fucking N:|\
fugue V:|\
fulcrum V:|\
fuller V:|\
fulminate N:|\
fun V:|\
functional N:|\
fungoid N:|\
furbelow V:|\
furnace V:|\
fusillade V:|\
gad N:|\
gaggle V:|\
gait V:|\
gallant V:|\
gammon V:|\
gander V:|\
gantlet V:|\
gap V:|\
gar V:|\
garble N:|\
garment V:|\
garner N:|\
garter V:|\
gash A:|\
gaudy N:|\
gauntlet V:|\
gavel V:|\
gavotte V:|\
gawk N:|\
gee N:|\
geld N:|\
gem V:|\
gender V:|\
gentle N:|\
geometric N:|\
geriatric N:|\
ghetto V:|\
gibber N:|\
giddy V:|\
gill V:|\
gimmick V:|\
ginger V:|\
gipsy V:|\
gird N:|\
girly N:|\
girth V:|\
glad V:|\
glassy N:|\
glee V:|\
glister N:|\
glitz V:|\
globe V:|\
gloom V:|\
gnawing N:|\
god V:|\
goddamn V:|\
godfather V:|\
gopher V:|\
gormandize N:|\
gospel V:|\
governess V:|\
gradient A:|\
gradual N:|\
grain V:|\
gravel A:|\
griddle V:|\
gridiron V:|\
groin V:|\
grommet V:|\
grouse A:|\
grubby N:|\
grubstake V:|\
grueling N:|\
gruelling N:|\
grump V:|\
guise V:|\
gulf V:|\
gullet V:|\
gully V:|\
gurgling N:|\
guts V:|\
gypsy A:|\
gypsy V:|\
gyrate A:|\
habit V:|\
hackle V:|\
haft V:|\
haggard N:|\
halcyon N:|\
halftone A:|\
hallo V:|\
handset V:|\
hangar V:|\
hangdog N:|\
hank V:|\
hap V:|\
haphazard N:|\
harbinger V:|\
hard N:|\
hardcore N:|\
hardy N:|\
hasp V:|\
hatchet V:|\
haunting N:|\
haven V:|\
havoc V:|\
haywire N:|\
heather A:|\
heir V:|\
hello V:|\
helm V:|\
helve V:|\
herbal N:|\
heroic N:|\
hi A:|\
highball V:|\
hill V:|\
hilltop V:|\
hilt V:|\
hippy A:|\
histrionic N:|\
hob V:|\
holograph V:|\
holy N:|\
honcho V:|\
hooky A:|\
horn V:|\
horselaugh V:|\
hosanna V:|\
hostage V:|\
hot V:|\
hovel V:|\
hover N:|\
howdy N:|\
hoyden A:|\
hub V:|\
hulk V:|\
hullo V:|\
hunky N:|\
hut V:|\
hymeneal N:|\
hymnal A:|\
hyper N:|\
hypo V:|\
illegitimate N:|\
illegitimate V:|\
illuminate N:|\
imaginary N:|\
immovable N:|\
immune N:|\
imp V:|\
implosive N:|\
impost V:|\
impotent N:|\
inane N:|\
incapable N:|\
incombustible N:|\
incoming N:|\
incorrigible N:|\
indefinable N:|\
indivisible N:|\
indulgence V:|\
industrial N:|\
inexpressible N:|\
infallible N:|\
infatuate N:|\
infect A:|\
infiltrate N:|\
infirm V:|\
inflammable N:|\
influential N:|\
ingot V:|\
ingrate A:|\
inlet V:|\
innermost N:|\
innumerate N:|\
insolent N:|\
insubordinate N:|\
insular N:|\
intaglio V:|\
interlinear N:|\
interlink N:|\
intermediate V:|\
intern A:|\
internal N:|\
interne V:|\
interplay V:|\
interstitial N:|\
interurban N:|\
interweave N:|\
intestate N:|\
intolerant N:|\
introvert V:|\
inverse V:|\
invisible N:|\
inward N:|\
iris V:|\
irony A:|\
irreconcilable N:|\
irresponsible N:|\
island V:|\
isle V:|\
isometric N:|\
isthmian N:|\
item V:|\
jack A:|\
jacket V:|\
jackrabbit V:|\
jag V:|\
japan A:|\
jargon V:|\
javelin V:|\
jeep V:|\
jerkwater N:|\
jetty A:|\
jetty V:|\
jitney V:|\
jobless N:|\
joist V:|\
journal V:|\
julienne N:|\
junketeer V:|\
jury V:|\
just V:|\
kelp V:|\
kerb V:|\
kernel V:|\
kibosh V:|\
kilt V:|\
kin A:|\
king V:|\
kit V:|\
kitten V:|\
kneel N:|\
knockdown A:|\
knoll V:|\
know N:|\
known N:|\
kosher N:|\
kraal V:|\
lachrymal N:|\
lackey V:|\
lackluster N:|\
lacklustre N:|\
lacrimal N:|\
lactate N:|\
lacteal N:|\
laden V:|\
lager V:|\
lair V:|\
lamp V:|\
landfill V:|\
landmark V:|\
lane A:|\
lantern V:|\
laryngeal N:|\
lasting N:|\
lattice V:|\
launder N:|\
laurel V:|\
law A:|\
law V:|\
lawyer V:|\
leach N:|\
leaden V:|\
leather V:|\
lech V:|\
lecher V:|\
ledge V:|\
legendary N:|\
legislative N:|\
legit N:|\
lenitive N:|\
lens V:|\
lesion V:|\
lesson V:|\
levee V:|\
lichen V:|\
lid V:|\
lifeguard V:|\
lighter V:|\
lightface A:|\
lilliputian N:|\
limb V:|\
limber N:|\
limited N:|\
lingual N:|\
lip V:|\
lit N:|\
liver V:|\
livery A:|\
loam V:|\
local V:|\
loco N:|\
loco V:|\
logistic N:|\
loll N:|\
longhand A:|\
loophole V:|\
lop N:|\
lot V:|\
lout V:|\
louver V:|\
lower N:|\
lowercase V:|\
lubber A:|\
lucky N:|\
luff N:|\
lullaby V:|\
lumbar N:|\
luminary A:|\
lunar N:|\
lurk N:|\
lush V:|\
luster V:|\
lustre V:|\
lute V:|\
macrame V:|\
macrobiotic N:|\
mad V:|\
mag V:|\
maim N:|\
main V:|\
mandamus V:|\
mandatory N:|\
maraud N:|\
margin V:|\
marl V:|\
mason V:|\
mast V:|\
masthead V:|\
matriculate N:|\
maxillary N:|\
maze V:|\
meagre N:|\
mechanical N:|\
medal V:|\
mediaeval N:|\
medial N:|\
medicine V:|\
medieval N:|\
medley A:|\
menthol A:|\
mercurial N:|\
meringue V:|\
messenger V:|\
metal V:|\
metallic N:|\
metric N:|\
metropolitan N:|\
mid N:|\
middle V:|\
middling N:|\
miff N:|\
minim A:|\
minion A:|\
missing V:|\
missive A:|\
mister V:|\
mock N:|\
modem V:|\
modular N:|\
monitory N:|\
monoclonal N:|\
monocular N:|\
monograph V:|\
montage V:|\
monument V:|\
moonwalk V:|\
moot N:|\
mordant V:|\
morph N:|\
morsel V:|\
mosaic V:|\
moss V:|\
motive V:|\
motorcade V:|\
mottle N:|\
moulder N:|\
mountebank V:|\
mud V:|\
muffle N:|\
mugger V:|\
mull N:|\
mullion V:|\
multiply A:|\
mum V:|\
mummy V:|\
murk A:|\
musky N:|\
must V|\
musty N:|\
mutual N:|\
nasty N:|\
naught A:|\
neat N:|\
necklace V:|\
negotiable N:|\
nett N:|\
nett V:|\
newsy N:|\
niche V:|\
nickel V:|\
nifty N:|\
nigger V:|\
nigh V:|\
nighttime A:|\
nocturnal N:|\
nominal N:|\
nonacademic N:|\
noncombustible N:|\
noncontributory N:|\
nondescript N:|\
noneffective N:|\
nonelectric N:|\
nonessential N:|\
nonmilitant N:|\
nonperishable N:|\
nonplus N:|\
nonresistant N:|\
nonstop N:|\
nontaxable N:|\
nonthinking N:|\
nonunion N:|\
nonvocal N:|\
noose V:|\
northeastward N:|\
northern N:|\
northward N:|\
northwestward N:|\
null V:|\
numeric N:|\
nursemaid V:|\
nutritive N:|\
oblate N:|\
oblique V:|\
obscure N:|\
observable N:|\
observant N:|\
occlusive N:|\
occult V:|\
ocher V:|\
ochre V:|\
octave A:|\
odd N:|\
off N:|\
officer V:|\
offprint V:|\
omen V:|\
omnipotent N:|\
omniscient N:|\
on N:|\
oncoming N:|\
opaque N:|\
ope A:|\
opiate V:|\
or N:|\
orb V:|\
orgasm V:|\
ornamental N:|\
ouch N:|\
ouch V:|\
ought N:|\
outcry V:|\
outspread N:|\
outward N:|\
over V:|\
overburden N:|\
overcoat V:|\
overdrive V:|\
overhand V:|\
overheat N:|\
overlord V:|\
overnight V:|\
overpass V:|\
overpraise N:|\
oversea N:|\
overshoot N:|\
overshot N:|\
oversize N:|\
overstock N:|\
oversupply N:|\
overtime V:|\
overture V:|\
overturn N:|\
overweight V:|\
owl V:|\
oyster V:|\
packet V:|\
palisade V:|\
pallet V:|\
palsy A:|\
pamphleteer V:|\
pappy A:|\
paraffin V:|\
paragon V:|\
paramount N:|\
parcel A:|\
parietal N:|\
paschal N:|\
passage V:|\
passe N:|\
pastor V:|\
pauper V:|\
pavilion V:|\
payable N:|\
payoff A:|\
peace V:|\
peach V:|\
peacock V:|\
peanut A:|\
pearly N:|\
peculiar N:|\
pedestal V:|\
peen V:|\
pellmell N:|\
penitential N:|\
penny A:|\
percipient N:|\
percolate N:|\
perk A:|\
persuasive N:|\
petrol V:|\
pharyngeal N:|\
philter V:|\
philtre V:|\
phonetic N:|\
phrenetic N:|\
picayune N:|\
pickaback N:|\
pie V:|\
piffle V:|\
pigment V:|\
pilgrimage V:|\
pill V:|\
pillar V:|\
pincer V:|\
pinnacle V:|\
pipeline V:|\
pipette V:|\
pique A:|\
pistol V:|\
pitapat V:|\
pith V:|\
plain V:|\
planetary N:|\
platy A:|\
plod N:|\
ploy V:|\
pluvial N:|\
pneumatic N:|\
poetic N:|\
poky N:|\
pollen V:|\
poltroon A:|\
pond V:|\
poniard V:|\
pontifical N:|\
pony V:|\
posit N:|\
post A:|\
postal N:|\
postcard V:|\
posthaste N:|\
potent N:|\
pour N:|\
praetorian N:|\
prank V:|\
precaution V:|\
precious N:|\
predecease N:|\
predicable N:|\
preempt N:|\
preen N:|\
preform N:|\
prelude V:|\
premature N:|\
premix N:|\
prescript A:|\
pretension V:|\
prevue V:|\
priest V:|\
prig V:|\
prim V:|\
prise N:|\
privateer V:|\
procedural N:|\
profound N:|\
prolog V:|\
prologue V:|\
prone N:|\
prong V:|\
propitiatory N:|\
proportionate V:|\
prose V:|\
protocol V:|\
prototype V:|\
proverb V:|\
provisional N:|\
provocative N:|\
prow A:|\
psalm V:|\
pshaw V:|\
pug V:|\
pumice V:|\
purple V:|\
pussyfoot N:|\
quad A:|\
quad V:|\
quadrennial N:|\
quicksilver V:|\
quill V:|\
quire V:|\
quirt V:|\
quitclaim V:|\
quoin V:|\
quotidian N:|\
qwerty N:|\
rabble V:|\
radiant N:|\
radiate A:|\
radiotelephone V:|\
rafter V:|\
ragout V:|\
raiment V:|\
rainproof V:|\
ramp V:|\
rampart V:|\
random N:|\
randy N:|\
rapture V:|\
ravening N:|\
rawhide V:|\
ray V:|\
razor V:|\
ready N:|\
real N|\
real N|\
rearguard A:|\
rearward N:|\
rebid N:|\
recalcitrant N:|\
recitative A:|\
reclaim N:|\
recommission N:|\
recontact N:|\
recoup N:|\
red V:|\
redirect A:|\
redouble N:|\
redraft N:|\
reductive N:|\
reed V:|\
reflex V:|\
refuge V:|\
regal N:|\
regale N:|\
regional N:|\
reload N:|\
remainder V:|\
remand N:|\
rematch V:|\
remit N:|\
remix N:|\
remnant A:|\
renege N:|\
renewable N:|\
renounce N:|\
reorient A:|\
repaint N:|\
repent A:|\
rephotograph N:|\
reprobate V:|\
reproductive N:|\
reptile A:|\
repurchase N:|\
resin V:|\
resistant N:|\
resonant N:|\
respite V:|\
respond N:|\
restudy N:|\
resurvey N:|\
retch N:|\
retinal N:|\
reveal N:|\
revere N:|\
reversible N:|\
revert N:|\
revoke N:|\
rhythmic N:|\
ribald N:|\
ribbon V:|\
riparian N:|\
ripsaw V:|\
roach V:|\
roam N:|\
rod V:|\
rode N:|\
rodeo V:|\
rogue V:|\
roomy N:|\
rose V:|\
rotate A:|\
roulette V:|\
rove N:|\
roving N:|\
rubber V:|\
rubric A:|\
rummy A:|\
rump A:|\
rural N:|\
rust A:|\
saber V:|\
sabre V:|\
sacramental N:|\
said N:|\
sailplane V:|\
saint V:|\
sallow N:|\
sallow V:|\
salsa V:|\
salutatory N:|\
salvo V:|\
sandal V:|\
sanguine N:|\
sanitarian A:|\
sash V:|\
sassy N:|\
saurian N:|\
scabbard V:|\
scaffold V:|\
scald A:|\
scamp V:|\
scandal V:|\
scenic N:|\
scepter V:|\
sceptre V:|\
schmooze N:|\
scholastic N:|\
schoolmaster V:|\
sciatic N:|\
sconce V:|\
scoot N:|\
scour N:|\
scow V:|\
scrag V:|\
scribe V:|\
scrooge V:|\
sear A:|\
sector V:|\
secular N:|\
sediment V:|\
seeming N:|\
seep N:|\
seethe N:|\
self V:|\
semiotic N:|\
semisolid N:|\
send N:|\
senile N:|\
sentient N:|\
sentinel V:|\
sere N:|\
serge V:|\
serpentine V:|\
serrate V:|\
servo V:|\
sewer V:|\
shack V:|\
shallow V:|\
shammy V:|\
shank V:|\
shanty V:|\
sheaf V:|\
sheave V:|\
sheen A:|\
sheen V:|\
sheeny N:|\
sheet V:|\
shelf V:|\
shier N:|\
shinny N:|\
shirk N:|\
shoal A:|\
shook N:|\
shore A:|\
shortwave V:|\
shorty A:|\
shot V:|\
shrimp A:|\
shrine V:|\
shut N:|\
sickly V:|\
siege V:|\
signet V:|\
significant N:|\
signore N:|\
silk V:|\
silkscreen A:|\
silo V:|\
silvan N:|\
simple N:|\
sinew V:|\
sirup V:|\
situate A:|\
skill V:|\
skoal V:|\
skulk N:|\
skyline V:|\
slag V:|\
slang V:|\
slat V:|\
sleeve V:|\
sleuth V:|\
slime V:|\
slink N:|\
slipcover V:|\
slipper V:|\
slipstream V:|\
slosh N:|\
slurry V:|\
slush V:|\
smith V:|\
smooth N:|\
smut V:|\
snafu A:|\
snafu V:|\
snapshot V:|\
snood V:|\
snoot V:|\
soaring N:|\
socket V:|\
sodden V:|\
soft N:|\
softbound N:|\
solar N:|\
sonnet V:|\
soot V:|\
sooth A:|\
sophomore A:|\
sorry N:|\
sourdough A:|\
south V:|\
southeastward N:|\
southwestward N:|\
spec A:|\
spelt N:|\
sphere V:|\
spiderweb V:|\
spire V:|\
splayfoot A:|\
splenetic N:|\
spoke V:|\
spouse V:|\
sprig V:|\
spud V:|\
spurn N:|\
squab A:|\
squadron V:|\
squander N:|\
squib V:|\
stadia N:|\
stag V:|\
stanch N:|\
stanchion V:|\
starboard V:|\
startle N:|\
stationary N:|\
statue V:|\
staunch N:|\
stead V:|\
steamer V:|\
steeplechase V:|\
stereo V:|\
stevedore V:|\
sticker V:|\
stifle N:|\
stigmatic N:|\
stiletto V:|\
stilt V:|\
stimulative N:|\
stooge V:|\
stool V:|\
story V:|\
stove V:|straightjacket V:|straightforward N\?:|strait A:|\
strata N:|streamline N:|stretcher V:|stun N:|sturdy N:|\
sty V:|subculture V:|sublimate N:|submarine V:|subnormal N:|\
substantial N:|subteen A:|subterranean N:|subway V:|sudden N:|\
suds V:|suede V:|suicide V:|sulfate V:|sulfur V:|sully N:|summit V:|\
sunburst A:|sundown V:|sunrise A:|superhuman N:|supine N:|supper V:|\
supple V:|supplemental N:|supplementary N:|supreme N:|surname V:|\
surrogate V:|surround N:|suspicion V:|swaddle N:|swan V:|\
sward V:|swinging N:|switchback V:|syllabic N:|syllable V:|syllogistic N:|\
sylvan N:|symbol V:|synapse V:|syrup V:|tabby V:|tabernacle V:|\
tablet V:|\
tabor V:|\
talc V:|\
tallow V:|\
tamper N:|\
tampon V:|\
tang V:|\
tapestry V:|\
tariff V:|\
tawdry N:|\
taxable N:|\
teach N:|\
teasel V:|\
teetotal V:|\
telegram V:|\
telemeter V:|\
tell N:|\
tempest V:|\
temporal N:|\
tenon V:|\
tension V:|\
tertiary N:|\
texture V:|\
theatrical N:|\
theme V:|\
therapeutic N:|\
thermostat V:|\
thickset N:|\
think N:|\
thole V:|\
thorn V:|\
thou V:|\
threat V:|\
throat V:|\
throne V:|\
thumbtack V:|\
thundering N:|\
ticktock V:|\
tier V:|\
tightrope V:|\
tiller V:|\
timber V:|\
tissue V:|\
titular N:|\
toenail V:|\
token V:|\
tole V:|\
tom V:|\
tomcat V:|\
tooth V:|\
tootle N:|\
topsoil V:|\
tore N:|\
torpid N:|\
torrent A:|\
tourney V:|\
tousle N:|\
toward A:|\
toxic N:|\
trance V:|\
transcendent N:|\
transcendental N:|\
tress V:|\
triage V:|\
trice V:|\
trifling N:|\
trig V:|\
trinket V:|\
trochaic N:|\
trolley V:|\
trolly V:|\
truce V:|\
truncheon V:|\
trustee V:|\
tub V:|\
tubercular N:|\
tun V:|\
turpentine V:|\
turtle V:|\
tusk V:|\
tutelary N:|\
twill V:|\
tyre V:|\
ugh N:|\
umber V:|\
umbilical N:|\
umlaut V:|\
underage N:|\
underbid N:|\
underlay V:|\
underwater N:|\
undress A:|\
unemployable N:|\
unessential N:|\
unicycle V:|\
unique N:|\
unite N:|\
unmarried N:|\
unpredictable N:|\
unprofessional N:|\
unquiet N:|\
unsteady V:|\
unthinkable N:|\
untidy V:|\
unwashed N:|\
unworkable N:|\
unworthy N:|\
uppercase V:|\
upright V:|\
upscale V:|\
upstage N:|\
upswing V:|\
urinary N:|\
valiant N:|\
vanish N:|\
vapor V:|\
vapour V:|\
venom V:|\
vermilion V:|\
vesiculate V:|\
vestibule V:|\
via N:|\
vial V:|\
vibrant N:|\
vinegar V:|\
vintage V:|\
viscose A:|\
visor V:|\
vitriol V:|\
vizor V:|\
vocable A:|\
volatile N:|\
volute A:|\
votary A:|\
vouch N:|\
voucher V:|\
vowel V:|\
vulgar N:|\
wafer V:|\
waggon V:|\
wagon V:|\
waiter V:|\
waitress V:|\
wan V:|\
wander N:|\
wardrobe V:|\
ware A:|\
ware V:|\
warm N:|\
watchdog V:|\
wattle A:|\
wavy N:|\
weapon V:|\
wearable N:|\
week A:|\
weeny N:|\
weird N:|\
wench V:|\
westward N:|\
wham A:|\
wharf V:|\
wheelbarrow V:|\
whereas N:|\
wherewith N:|\
wherry V:|\
whet N:|\
whew N:|\
whiplash V:|\
whist A:|\
whist V:|\
white V:|\
whittle N:|\
whore V:|\
wick V:|\
wide N:|\
wife V:|\
willow V:|\
windlass V:|\
window V:|\
windrow V:|\
winnow N:|\
wireless V:|\
wise V:|\
wisp V:|\
without N:|\
witting N:|\
wizard A:|\
woman V:|\
won V:|\
wont V:|\
woodshed V:|\
workday A:|\
worth V:|\
wrack V:|\
wrath A:|\
wreath V:|\
yard V:|\
yarn V:|\
yawl V:|\
yearling A:|\
yeast V:|\
yen V:|\
yore A:|\
yummy N:|\
zest V:|\
zillion A:|\
on N:|rockies N:|known N:|as A:|albert[ \t]N|i A:|her A:|allies[\t]N|then N:|donuts N\?:|us N:|\
less N:|more N:|toward N\?:|anyhow A:|again A:|nope A:|\
forth A:|askance A:|aloud A:|aloft A:|\
afresh A:|all A:|quite A:|hence A:|ergo A:|almost A:|although A:|then A:|\
thereof A:|most A:|too A:|therein A:|out A:|indeed A:|whereof A:|\
in A:|twice A:|viva A:|not A:|often A:|once A:|never A:|nowhere A:|\
where A:|wherein A:|t A:|ago A:|atop A:|notwithstanding A:|\
away A:|very A:|daily A:|why A:|yet A:|since A:|after A:|before A:|\
about A:|brother A:|sister A:|\
feces N:|axes\tN|bases\tN|phenomena[ \t]N[:]*|automata\tN|cherubim[ \t]N[:]*|\
apices\tN|cervices\tN|indices\tN|matrices\tN|vortices\tN|\
elves\tN|halves\tN|hooves\tN|knives\tN|leaves\tN|lives\tN|loaves\tN|\
scarves\tN|selves\tN|sheaves\tN|shelves\tN|wives\tN|wolves\tN|geese\tN|\
lice\tN|mice\tN|children\tN|corpora[ \t]N[:]*|genera\tN|foci\tN|fungi\tN|\
nuclei\tN|radii\tN|stimuli\tN|syllabi\tN|bacteria[ \t]N[:]*|data\tN|errata[ \t]N[:]*|\
media[ \t]N[:]*|memoranda[ \t]N[:]*|ova\tN|strata[ \t]N[:]*|oxen[ \t]N[:]*|calves\tN|feet\tN|\
women\tN|men\tN|well A:|who[ \t]N[:]*|an A:|an[ \t]DCN|themselves N:|\
a[ \t]DNVP|He[ \t]N[:]*|me[ \t]N[:]*|he[ \t]N[:]*|I[ \t]N[:]*|this[ \t]N[:]*|\
that[ \t][AN][:]*|such[ \t]N[:]*|his[ \t]N[:]*|t[ \t]N[:]*|she[ \t]N[:]*|\
you[ \t]N[:]*|we[ \t]N[:]*|they[ \t]N[:]*|them[ \t]N[:]*|him[ \t]N[:]*|\
her[ \t]N[:]*|your[ \t][NA][:]*|my[ \t]N[:]*|herself[ \t]N[:]*|\
himself[ \t]N[:]*|it[ \t]N[:]*|itself[ \t]N[:]*|myself[ \t]N[:]*|\
oneself[ \t]N[:]*|our[ \t]N[:]*|our[ \t]A[:]*|their[ \t]|\
yourself[ \t]N[:]*|ourself[ \t]N[:]*|another[ \t]N[:]*|and[ \t]N[:]*|\
any[ \t]A[:]*|all[ \t]A[:]*|an[ \t]N[:]*|each[ \t]A[:]*|either[ \t]A[:]*|\
every[ \t]A[:]*|half[ \t]A[:]*|many[ \t]N[:]*|many[ \t]A[:]*|\
much[ \t]N[:]*|neither[ \t]A[:]*|no[ \t]A[:]*|some[ \t]N[:]*|\
some[ \t]A[:]*|such[ \t]A[:]*|those[ \t]N[:]*|those[ \t]A[:]*|\
these[ \t]N[:]*|those[ \t]A[:]*|and[ \t]N\?[:]*|within[ \t]|this[ \t]A[:]*|\
into[ \t]N[:]*|what[ \t][NA][:]*|whom[ \t][NA][:]*|whose[ \t][NA][:]*|\
which[ \t]N[:]*|which[ \t]A[:]*|there[ \t]|will[ \t]V[:]*|\
can[ \t]V[:]*|may[ \t]V[:]*|shall[ \t]V[:]*|ought[ \t]V[:]*|must[ \t]V[:]*|\
could[ \t]V[:]*|would[ \t]V[:]*|inter[ \t]A[:]*|school[ \t]A[:]*|\
the[ \t]A[:]*|mod[ \t]A:)/ && !/'/