Is it possible mawk does not use zero-based indices?

ie:
mawk substr(x, 1, 1)
gawk  substr(x, 0, 1)

Should return the same thing

from man awk:

"       Finally,  here  is  how mawk handles exceptional cases not discussed in
       the AWK book or the Posix draft.  It is unsafe  to  assume  consistency
       across awks and safe to skip to the next section.

              substr(s,  i, n) returns the characters of s in the intersection
              of the closed interval [1, length(s)] and the half-open interval
              [i,  i+n).  When this intersection is empty, the empty string is
              returned; so substr("ABC", 1, 0) = "" and substr("ABC", -4, 6) =
              "A".
"

On 4/11/06, Rene Kalff <[EMAIL PROTECTED]> wrote:
> Can anyone tell me why mawk is chosen as the default awk package instead
> of gawk?
>
> On Tue, 2006-04-11 at 21:19 +0200, Rene Kalff wrote:
> > Dear all,
> >
> > have a rather "interesting" problem with mawk. Aperently the substr
> > functions doesn't work as excepted.
> > Have a look at the following:
> >
> > bash# echo test1 | mawk '{print substr($1, 0, 5)}'
> > bash# test
> >
> > I've also installed gawk:
> > bash# echo test1 | gawk '{print substr($1, 0, 5)}'
> > bash# test1
> >
> > As the awk functions are very common I can't believe that this isn't
> > noticed till now, or that it happens with all Arch installations?
> > Anybody how can tell my if this also happens at their systems or maybe
> > has an idea solving this problem besides replacing mawk with gawk?
> >
> >
> > --
> > With kind regards,
> >
> > Rene Kalff
> > Dasensys
> >
> > Stougjesdijk 83
> > 3273 LM Westmaas
> > The Netherlands
> >
> > T. +31 (0)186 575 423
> > F. +31 (0)186 575 478
> > E. [EMAIL PROTECTED]
> > _______________________________________________
> > arch mailing list
> > [email protected]
> > http://www.archlinux.org/mailman/listinfo/arch
> --
> With kind regards,
>
> Rene Kalff
> Dasensys
>
> Stougjesdijk 83
> 3273 LM Westmaas
> The Netherlands
>
> T. +31 (0)186 575 423
> F. +31 (0)186 575 478
> E. [EMAIL PROTECTED]
>
>
> _______________________________________________
> arch mailing list
> [email protected]
> http://www.archlinux.org/mailman/listinfo/arch
>

_______________________________________________
arch mailing list
[email protected]
http://www.archlinux.org/mailman/listinfo/arch

Reply via email to