Annotation of researchv10no/cmd/prefer/misc/pdoc.sh, revision 1.1

1.1     ! root        1: sed '
        !             2: /^%A/  s/%A /%author /
        !             3: /^%B/  s/%B /%booktitle /
        !             4: /^%C/  s/%C /%address /
        !             5: /^%d/  s/%d /%date /
        !             6: /^%D/  s/%D /%date /
        !             7: /^%E/  s/%E /%editor /
        !             8: /^%G/  s/%G /%government /
        !             9: /^%I/  s/%I /%publisher /
        !            10: /^%J/  s/%J /%journal /
        !            11: /^%K/  s/%K /%keyword /
        !            12: /^%L/  s/%L /%label /
        !            13: /^%M/  s/%M /%tm /
        !            14: /^%N/  s/%N /%number /
        !            15: /^%O/  s/%O /%other /
        !            16: /^%P/  s/%P /%pages /
        !            17: /^%r/  s/%r /%report /
        !            18: /^%R/  s/%R /%report /
        !            19: /^%T/  s/%T /%title /
        !            20: /^%V/  s/%V /%volume /
        !            21: ' $1 | sed '
        !            22: /\.\[/ N
        !            23: /\.\[\n\$LIST\$/ N
        !            24: /\.\[\n\$LIST\$\n\.\]/ c\
        !            25: |reference_placement
        !            26: /^\.\[/ s/\.\[/|reference</
        !            27: /^\.\]/ s/\.\]/%type >/
        !            28: ' | awk '
        !            29: BEGIN  {typestr = "%type"; edstr = "%editor"; reffields = 0;}
        !            30: 
        !            31: 
        !            32: /^%/   {
        !            33:        if(($1 != "%author") && ($1 != "%publisher") && ($1 != "%type"))
        !            34:                print; 
        !            35:        if($1 != "%editor")
        !            36:                ineditor = 0
        !            37:        if($1 != "%type") reffields++;
        !            38: }
        !            39: 
        !            40: $1 == "%author"        {
        !            41:        if ($NF ~ /\([Ee]d.*\)/) {
        !            42:                edited++;
        !            43:                $NF = "";
        !            44:        }
        !            45:        print;
        !            46: }
        !            47: 
        !            48: $1 == "%publisher"     {
        !            49:        publisher++ ;
        !            50:        if($2 == "PhD") {
        !            51:                phd++;
        !            52:                printf "%s", $1;
        !            53:                for (i=4; i <= NF; i++)
        !            54:                        printf " %s", $i;
        !            55:                print "";
        !            56:        }
        !            57:        else if($2 ~ /Master*/) {
        !            58:                masters++;
        !            59:                printf "%s",$1;
        !            60:                for (i=4; i <= NF; i++)
        !            61:                        printf " %s", $i;
        !            62:                print "";
        !            63:        }
        !            64:        else print;
        !            65: }
        !            66: 
        !            67: $1 == "%editor"                { editor++; ineditor = 1;}
        !            68: $1 == "%author"                { author++ }
        !            69: $1 == "%journal"       { journal++ }
        !            70: $1 == "%tm"            { tm++ }
        !            71: $1 == "%report"                { report++ }
        !            72: $1 == "%booktitle"     { booktitle++ }
        !            73: /[Pp]roc/ || /[Cc]onf/ { if ($1 == "%journal") inproceedings++;}
        !            74: 
        !            75: /^[^%]/        {               # handle multiple editors
        !            76:        if(ineditor) {
        !            77:                printf "%s ", edstr;
        !            78:                if($1 == "and")
        !            79:                        print substr($0,length($1)+2);
        !            80:                else
        !            81:                        print;
        !            82:        }
        !            83:        else print;
        !            84: }
        !            85: /^$/   {print}         # blank lines
        !            86: 
        !            87: # now infer document type
        !            88: $1 == "%type"  {
        !            89:        if(reffields) {
        !            90:                printf "%s ", typestr;
        !            91:                if(edited) print "editedbook";
        !            92:                else if(masters) print "mastersthesis";
        !            93:                else if(phd) print "phdthesis";
        !            94:                else if(inproceedings) print "inproceedings";
        !            95:                else if(journal) print "article";
        !            96:                else if(booktitle) print "incollection";
        !            97:                else if(tm) print "tm";
        !            98:                else if(report) print "techreport";
        !            99:                else if(publisher) print "book";
        !           100:                else print "misc";
        !           101:        }
        !           102:        print ">";
        !           103: 
        !           104:        editor = 0;
        !           105:        author = 0;
        !           106:        journal = 0;
        !           107:        inproceedings = 0;
        !           108:        booktitle = 0;
        !           109:        publisher = 0;
        !           110:        tm = 0;
        !           111:        report = 0;
        !           112:        book = 0;
        !           113:        tflag = 0;
        !           114:        ineditor = 0;
        !           115:        phd = 0;
        !           116:        masters = 0;
        !           117:        edited = 0;
        !           118:        reffields = 0;
        !           119: }
        !           120: '

unix.superglobalmegacorp.com

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