Re: perl

From: <abc@dont-contact.us>
Date: Tue, 21 Feb 2006 03:18:44 GMT

> > thank you for your reply.
> > i would be happy to help and write what is required.
> > i am very proficient with awk - but i do not know
> > exactly what the perl scripts do - i don't know
> > perl. if you could specify the I/O requirements
> > of the scripts, and what files they operate upon,
> > i would be happy to do the work.
>
> The two scripts just derives some trivial parts of the code.

ok - well these should do things smaller, faster,
and without 13-100MB of perl installation. Thank you :)
-------------------------------------------------------------------------------

# tested with gawk, mawk, and nawk.
# drop-in replacement for mk-globals-c.pl.
# creates "globals.c" (on stdout) from "globals.h".
# invoke similarly: perl -f mk-globals-c.pl globals.h
# --> awk -f mk-globals-c.awk globals.h
#
# 2006 by Christopher Kerr.

BEGIN { print "#include squid.h" }

/^ \*\/$/ && !Copyright { print; Copyright = 1; next }
!Copyright { print; next }

/^extern / {

    sub(/extern /, ""); sub(/;.*\/\*/, " =")
    sub(/ \*\/.*/, ";"); print; next
}
// { print }

-------------------------------------------------------------------------------

# tested with gawk, mawk, and nawk.
# drop-in replacement for mk-string-arrays.pl.
# creates "enum.c" (on stdout) from "enum.h".
# invoke similarly: perl -f mk-string-arrays.pl enum.h
# --> awk -f mk-string-arrays.awk enum.h
#
# 2006 by Christopher Kerr.

BEGIN { # converted to "const char *"TypedefEnum[?]"_str[]"

    TypedefEnum[1]="err_type"
    TypedefEnum[2]="lookup_t"
    TypedefEnum[3]="icp_opcode"
    TypedefEnum[4]="swap_log_op"
}
/^ \*\/$/ && !Copyright { print; Copyright = 1; next }
!Copyright { print; next }

/ *[A-Z_,]+$/ { sub(/^ */, ""); Element[++e] = $0 }
/^}/ { sub(/} */, ""); sub(/;.*/, "")

    for ( te = 1; TypedefEnum[te]; ++te )

        if ( $0 == TypedefEnum[te] ) {

            print "\nconst char *" $0 "_str[] = {\n"
            for ( i = 1; i <= e; ++i) print " "Element[i]
        }
        delete Element; e = 0

-------------------------------------------------------------------------------
Received on Tue Feb 21 2006 - 06:19:23 MST

This archive was generated by hypermail pre-2.1.9 : Tue Feb 28 2006 - 12:00:05 MST