webrev -f not working?
Magnus Ihse Bursie
magnus.ihse.bursie at oracle.com
Fri Nov 7 07:29:39 UTC 2014
On 2014-11-05 17:43, Daniel Fuchs wrote:
> Hi Magnus,
>
> Here is a small testcase:
>
> $ echo '[blah/blah]' | gawk '{print substr($1,2,length($1)-1);}'
> blah/blah]
> $ echo '[blah/blah]' | gawk '{print substr($1,2,length($1)-2);}'
> blah/blah
>
> I suspect you won't get the same result on your machine :-(
But I do. But here's the trick, try:
magnusi at sthihse3:~$ echo '[blah/blah]' | awk '{print
substr($1,0,length($1)-2);}'
[blah/bl
magnusi at sthihse3:~$ echo '[blah/blah]' | awk '{print
substr($1,1,length($1)-2);}'
[blah/bla
I'm using nawk. While both gawk and nawk use 1 as the index for the
first position, using 0 exposes different behaviours. Gawk, according to
the manual, will interpret everything < 1 as 1. Nawk, on the other hand,
apparently interprets a position 0 as a "-1".
So here's an updated patch that will probably work for you as well as
for me:
diff --git a/webrev.ksh b/webrev.ksh
--- a/webrev.ksh
+++ b/webrev.ksh
@@ -1420,7 +1420,7 @@
# the AWK code which still tries to handle both cases
#
hg tstatus -mdn $FSTAT_OPT 2>/dev/null | $FILTER | $AWK -v
"hgroot=$hgroot" '
- /^\[.*\]:$/ {tree=substr($1,length(hgroot)+3);
tree=substr(tree,0,length(tree)-2); next}
+ /^\[.*\]:$/ {tree=substr($1,length(hgroot)+3);
tree=substr(tree,1,length(tree)-2); next}
$1 != "" {n=index($1,tree);
if (n != 1)
{ printf("%s/%s\n",tree,$1)}
/Magnus
More information about the webrev-dev
mailing list