For Programmers: Free Programming Magazines  


Home > Archive > AWK > March 2008 > [announce] runawk-0.12.0 released









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author [announce] runawk-0.12.0 released
Aleksey Cheusov

2008-03-03, 10:00 pm

runawk-0.12.0 has been released
Source code is available from http://sourceforge.net/projects/runawk

Feedback is welcome


Major changes:

new directive '#env' is implemented.
It sets environment for running awk subprocess using putenv(3)

Example:

#!/usr/local/bin/runawk

#env "LC_ALL=C"

$1 ~ /^[A-Z]+$/ { # A-Z is valid if LC_CTYPE=C
print $1
}

New modules

match_br.awk

match_br(STRING, BR_OPEN, BR_CLOSE)
return start position (or zero if failure) of the substring
surrounded by balanced (), [], {} or similar characters
Also sets RSTART and RLENGTH variables just like
the standard 'match' function does

For example:
print match_br("A (B (), C(D,C,F (), 123))", "(", ")")
print RSTART, RLENGTH
-| 3
-| 3
-| 24

braceexpand.awk

braceexp(STRING)
implement shell-like brace expansion

For example:
print braceexpand("ab{,22{,7,8}}z{8,9}")
-| abz8 abz9 ab22z8 ab22z9 ab227z8 ab227z9 ab228z8 ab228z9

exitnow.awk

see the code. exitnow.awk is used by alt_assert.awk and
abort.awk

abort.awk

abort(MSG, EXIT_STATUS) -- print MSG to stderr and exits
program with EXIT_STATUS. if EXIT_STATUS is zero of is not
specified, 1 is assigned.

dirname.awk

similar to UNIX's dirname(1)

basename.awk

similar to UNIX's basename(1)

xgetline.awk

xgetline0([FILE])

Safe analog to 'getline < FILE' or 'getline' (if no FILE
is specified). 0 at the end means that input line is
assigned to $0.

xgetline([FILE])
Safe analog to 'getline __input < FILE' and 'getline __input'
(if no FILE is specified)

In both cases "safe" means that returned value is analysed
and if it is less than zero (file reading error happens)
program will be terminated emmidiately with appropriate error
message printed to stderr. Both functions return zero if end
of file is reached or non-zero if reading was sucessfull.

Example:
while (xgetline("/etc/passwd")){
print "user: " __input
}

xclose.awk
xsystem.awk -- safe wrappers over 'close' and 'system' functions

--
Best regards, Aleksey Cheusov.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com