Annotation of researchv10no/cmd/netnews/config/options.awk, revision 1.1

1.1     ! root        1: BEGIN {
        !             2:        i = 0;
        !             3:        eflag = 0;
        !             4:        User = Inmake = Indefs = 0;
        !             5:        version = "v7";
        !             6:        Makefile = install = postnews = "";
        !             7: }
        !             8: 
        !             9: /^#/   {next;}
        !            10: /^[    ]*$/    {next;}
        !            11: 
        !            12: /^@@BeginMakefile$/    {Inmake = 1; next;}
        !            13: /^@@EndMakefile$/      {Inmake = 0; next;}
        !            14: /^@@BeginDefs$/        {Indefs = 1; next;}
        !            15: /^@@EndDefs$/  {Indefs = 0; next;}
        !            16: /^@@BeginUser$/        {User = 1; next;}
        !            17: 
        !            18: $1 == version {version = $1; next;}
        !            19: $1 == Makefile {Makefile = $1; next;}
        !            20: $1 == postnews {postnews = $1; next;}
        !            21: $1 == install {install = $1; next;}
        !            22: 
        !            23: {
        !            24:        if ((Inmake + Indefs + User) != 1) {
        !            25:                printf "sequence error\n";
        !            26:                eflag = 1;
        !            27:                exit;
        !            28:        }
        !            29:        if ($1 ~ /^\+/) {omit = 0; nm = substr($1, 2, length($1)-1);}
        !            30:        else if ($1 ~ /^\-/) {omit = 1; nm = substr($1, 2, length($1)-1);}
        !            31:        else {omit = 0; nm = $1;}
        !            32: 
        !            33:        if (!User) {
        !            34:                Mkparm[i] = Inmake;
        !            35:                opt[i++] = nm;
        !            36:                valid[nm] = "ok";
        !            37:        }
        !            38:        else if (valid[nm] == "") {
        !            39:                printf "%s: invalid option\n", nm;
        !            40:                eflag = 1;
        !            41:                next;
        !            42:        }
        !            43:        if (omit) {
        !            44:                Omit[nm] = 1;
        !            45:                next;
        !            46:        }
        !            47:        else Omit[nm] = 0;
        !            48: 
        !            49:        if (NF >= 2) {
        !            50:                val =$2;
        !            51:                for (j = 3; j <= NF; j++)
        !            52:                        val = sprintf("%s=%s", val, $(j));
        !            53:                gotit[nm] = val;
        !            54:        }
        !            55: }
        !            56: 
        !            57: END {
        !            58:        if (eflag) {
        !            59:                printf "echo No defs.h file created\n";
        !            60:                exit;
        !            61:        }
        !            62:        if (Makefile == "") Makefile = version;
        !            63:        if (postnews == "") postnews = version;
        !            64:        if (install == "") install = version;
        !            65:        printf "cp defs.templ defs.h; chmod +w defs.h\n";
        !            66:        printf "ed - defs.h <<'EOF'\n";
        !            67:        for (j = 0; j < i; j++) {
        !            68:                if (Mkparm[j]) continue;
        !            69:                vl=opt[j];
        !            70:                do=gotit[vl];
        !            71:                if (Omit[vl])
        !            72:                        printf "g/^#define[     ]*%s[   ]/s~^~/* ~\n", vl;
        !            73:                else if (do != "")
        !            74:                        printf "g/^#define[     ]*%s[   ]/s~@@~%s~\n", vl, do;
        !            75:        }
        !            76:        printf "w\nq\nEOF\n";
        !            77:        printf "cat >Makefile <<'EOF'\n";
        !            78:        for (j = 0; j < i; j++) {
        !            79:                if (Mkparm[j]) {
        !            80:                        vl=opt[j];
        !            81:                        printf "%s=", vl;
        !            82:                        if (!Omit[vl])
        !            83:                                printf "%s", gotit[vl];
        !            84:                        printf "\n";
        !            85:                }
        !            86:        }
        !            87:        printf "EOF\ncat Makefile.%s >>Makefile\n", Makefile;
        !            88:        printf "cp postnews.%s postnews; chmod +x postnews\n", postnews;
        !            89:        printf "cp install.%s install; chmod +x install\n", install;
        !            90: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.