Re: [mu SETUP] Can't change to static / bitwise ops in 'awk'

From: Alfie Costa ([email protected])
Date: Sat Apr 13 2002 - 21:12:29 CEST


On 12 Apr 2002, at 15:37, Michele Andreoli <[email protected]> wrote:

> I solved the problem, enhancing a little the "expr" command: now it
> is able to to logical bitwise operation such
>
> # expr 4 & 255
> # expr ~ 4
>
> etc (must quote \&, \~).
> After that, I changed the ip_network and the ip_broadcast AWK script,
> calling the external program expr (ugly, but awk do not seems to support
> this kind of C language operation).

Doubting this, I looked in the mawk manual. Yet it's true, there are no
bitwise operators in awk, maybe because there's no declared number types.

I got to thinking "how hard can it be?" Thus:

        http://www.gis.net/~agcosta/mu_files/awktest.gz (410 bytes)

(Answer: harder than it looked.)

Note that the kludges, or functions, (bit_and(), bit_or(), bit_xor(), and
bit_not()), don't understand two's complement negative numbers. Maybe there's
too many variables, and somebody here on the list knows how to simplify the
code.

It's redundant, given the new 'expr' changes, but if you still want bitwise
functions in 'awk'...

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



This archive was generated by hypermail 2.1.6 : Sat Feb 08 2003 - 15:27:21 CET