#!/bin/sh edit() { awk -v edit="$1" -v "fn=$2" ' function warn(msg) { print fn ": " msg } function print_contact() { print " * Contact:" print " * Project page: http://repo.hu/projects/pcb-rnd" print " * lead developer: email to pcb-rnd (at) igor2.repo.hu" print " * mailing list: pcb-rnd (at) list.repo.hu (send \"subscribe\")" } /[*].*(C).*199[0-9]/ { cy=1 } /[*].*(C).*20[0-9][0-9]/ { cy=1 } /\/[*] *[aA]utogenerated/ { autogen++ } /COPYRIGHT/ { if (edit) print $0; copy=1; seen_copy=1; next } (!copy) { if (edit) print $0; next } (copy) && /pcb-rnd, interactive printed circuit board design/ { pcb_rnd++ } (copy) && /PCB, *interactive printed circuit board design/ && !/[(]/ { if (edit) { print " * pcb-rnd, interactive printed circuit board design" print " * (this file is based on PCB, interactive printed circuit board design)" next } else warn("PCB project tag") old_pcb++ } (copy) && /^ *[*]/ { indbug++ } (copy) && (new_cont) && /repo.hu/ { repohu=1 } (copy) && /Contact:/ { new_cont = 1 } (copy) && /Contact addresses for/ { # read all lines of the contact contact++; while((getline line) == 1) { ocont = ocont line "\n" if (line ~ "Thomas[.]Nau") { if (!edit) warn("Old contact address: Thomas Nau") tnau++ } if (!(line ~ "[a-zA-Z]")) { break; } } $0 = line if (edit) { print_contact() if ((!tnau) && (!repohu)) { print " *" print " * Old contact info:" printf("%s", ocont) } } } (copy) && /[*]\// { # end of copyright copy = 0 if (!repohu) { if (edit) print_contact() else warn("missing repo.hu contact") } } { if (edit) print $0 } END { if ((!edit) && (!autogen)) { if (!seen_copy) { if (cy) warn("non-standard copyright banner") else warn("missing copyright banner") } if ((!pcb_rnd) && (cy)) warn("missing pcb-rnd project banner") if (indbug) warn("broken indentation") } } ' } case "$1" in -f|--fix) cmd=fix; shift 1;; esac case "$cmd" in fix) for fn in $* do edit 1 "$fn" < $fn > $fn.lic mv $fn.lic $fn done ;; *) for fn in $* do edit 0 "$fn" < $fn done ;; esac