[ANN][VM][SF] my Unix patches integrated into SF layout
Greg A. Woods
woods at weird.com
Wed Jan 2 21:57:02 UTC 2002
[ On Tuesday, January 1, 2002 at 19:13:50 (-0400), Lex Spoon wrote: ]
> Subject: Re: [ANN][VM][SF] my Unix patches integrated into SF layout
>
> Drats -- different awk's seem to do handle substr() differently -- just
> try the output of this under gawk versus mawk:
>
> gawk 'BEGIN {print substr("12:",0,2); }'
That's because you're using substr() incorrectly. Try the following:
$ANYAWK 'BEGIN {print substr("12:", 1, 2); }'
Note the definition (from "The One True AWK" manual page):
substr(s, m, n)
the n-character substring of s that begins at position m
counted from 1.
As far as I can remember all AWK strings are counted from 1, not zero,
though it seems only the real AWK manual is careful enough to say this
explicitly for substr().
--
Greg A. Woods
+1 416 218-0098; <gwoods at acm.org>; <g.a.woods at ieee.org>; <woods at robohack.ca>
Planix, Inc. <woods at planix.com>; VE3TCP; Secrets of the Weird <woods at weird.com>
More information about the Squeak-dev
mailing list
|