バックアップ下ncc

2890 ワード

##  libpcap.tar.gz; ./ncc.sh 
## ncc.sh

inswning()
{
    for f in `find $1 -type f -name "*.[ch]"`; do
        if [ ! -w $f ]; then sudo chmod 646 $f; echo chmod $f; fi
        if [ ! -w $f ]; then echo read only $f && exit 1; fi

        mv $f a.tmp
        awk -v dirpath=${f%/*} '
            BEGIN {print "#warning " dirpath " z53950"}
            /^[ \t]*#[ \t]*(if|ifdef|ifndef|endif|elif|else)/ {flag=1}
            {
                print;
                if(flag == 1 && $NF != "\\"){ flag=0; print "#warning " dirpath " z53950"; }
            }
        ' a.tmp > $f
    done
}

tar -zxf ../libpcap-1.3.0.tar.gz
pushd libpcap-1.3.0

sudo ./configure

find . -type f -name "*.c" > cfile.log
find . -type f -name "*.h" > hfile.log

inswning .

sudo make 2> make_wn.log

grep ".*\.c:.* z53950" make_wn.log | sort -u > wnc.log

awk -f ../strwn.awk wnc.log cfile.log

make clean
for f in `find . -type f -name "*.[.ch]"`; do
    mv $f a.tmp
    grep -v "z53950$" a.tmp > $f
done
sudo make
md5sum *so*

## strwn.awk
BEGIN {
    FS = ":"
    while(getline < ARGV[1] > 0) warn[$1 ":" $2] = 1;
    FS = "[ \t]+"
}

{
    while(getline < ARGV[2] > 0) {
        file = $1;
        line=0;
        out=""
        while(getline < file > 0)
        {
            line++;
            if ($NF == "z53950") {
               str = file ":" line;
               if (str in warn) yes=1; else yes=0
            } else if ($0 ~ /^[ \t]*#[ \t]*(if|ifdef|ifndef|elif|else|endif)/) {
                ifdef = 1
            }

            if (ifdef == 1 && $NF != "\\"){
                ifdef = 0; out = out $0 "
"             } else if (yes == 1 || ifdef ==1) {                 out = out $0 "
"             } else {                 out = out "///:" $0 "
"             }         }         print out > file     } }  

/////
./bpf_dump.c:1:2: warning: #warning . z53950 ./bpf_dump.c:23:2: warning: #warning . z53950 ./bpf_dump.c:27:2: warning: #warning . z53950 ./bpf_dump.c:30:2: warning: #warning . z53950 ./bpf_dump.c:33:2: warning: #warning . z53950 ./bpf_dump.c:66:2: warning: #warning . z53950 bpf_filter.c:102:2: warning: #warning ./bpf/net z53950 bpf_filter.c:105:2: warning: #warning ./bpf/net z53950 bpf_filter.c:111:2: warning: #warning ./bpf/net z53950 bpf_filter.c:124:2: warning: #warning ./bpf/net z53950
#line 200//次の行の指定_LINE__200 main(){printf("%d",_LINE_);//出力202
BEGIN{
    FS="
" RS=")
{" t=1 } { if (t == 1) {t=2;printf "%s", $0} else{ printf ")
{printf();%s", $0 } }

=============