xfstests: don't remove trailing zeros from integers
PATCH v2 1/1 xfstests: don't remove trailing zeros from integers
_within_tolerance strips trailing zeros from the min and max range values it outputs. This leads to damage if the min or max value is an integer containing trailing zeros rather than a real number with a fractional part containing trailing zeros. Xfstest 289 can exhibit this problem when its input is out of range. Modify the code so it will only remove trailing zeros found after a decimal point, and remove decimal points not followed by digits.
--- common.filter | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
common.filter +5 -2
@@ -106,8 +106,11 @@ EOF # fix up min, max precision for output # can vary for 5.3, 6.2 - _min=`echo $_min | sed -e 's/0*$//'` # get rid of trailling zeroes - _max=`echo $_max | sed -e 's/0*$//'` # get rid of trailling zeroes + + # remove any trailing zeroes from min, max if they have fractional parts + # and then remove any decimal points not followed by digits + _min=`echo $_min | sed -e '/\./s/0*$//' | sed -e 's/\.$//'` + _max=`echo $_max | sed -e '/\./s/0*$//' | sed -e 's/\.$//'` if [ $_in_range -eq 1 ] then
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 18 lines · Eric Whitney
_within_tolerancestrips trailing zeros from the min and max range values it outputs. This leads to damage if the min or max value is an integer containing trailing zeros rather than a real number with a fractional part containing trailing zeros. Xfstest 289 can exhibit this problem when its input is out of range. Modify the code so it will only remove trailing zeros found after a decimal point, and remove decimal points not followed by digits.Signed-off-by Eric Whitney <[email protected]>--- common.filter | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)common.filter +0
-0
common.filter EOF · line 113
Quoted 10 lines
common.filter +5
-2@@ -106,8 +106,11 @@ EOF # fix up min, max precision for output # can vary for 5.3, 6.2 - _min=`echo $_min | sed -e 's/0*$//'` # get rid of trailling zeroes - _max=`echo $_max | sed -e 's/0*$//'` # get rid of trailling zeroes + + # remove any trailing zeroes from min, max if they have fractional parts + # and then remove any decimal points not followed by digits + _min=`echo $_min | sed -e '/\./s/0*$//' | sed -e 's/\.$//'` + _max=`echo $_max | sed -e '/\./s/0*$//' | sed -e 's/\.$//'`
You can do this with a single sed invocation via multiple expressions:
$ echo 200.00 | sed -e '/\./s/0*$//' -e 's/\.$//' 200 $
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 20 lines · Dave Chinner
Quoted 19 lines · Eric Whitney
_within_tolerancestrips trailing zeros from the min and max range values it outputs. This leads to damage if the min or max value is an integer containing trailing zeros rather than a real number with a fractional part containing trailing zeros. Xfstest 289 can exhibit this problem when its input is out of range. Modify the code so it will only remove trailing zeros found after a decimal point, and remove decimal points not followed by digits.Signed-off-by Eric Whitney <[email protected]>--- common.filter | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)common.filter +0
-0@@ -106,8 +106,11 @@ EOF
Quoted 9 lines
common.filter EOF · line 113
Quoted 9 lines
common.filter +5
-2# fix up min, max precision for output # can vary for 5.3, 6.2 - _min=`echo $_min | sed -e 's/0*$//'` # get rid of trailling zeroes - _max=`echo $_max | sed -e 's/0*$//'` # get rid of trailling zeroes + + # remove any trailing zeroes from min, max if they have fractional parts + # and then remove any decimal points not followed by digits + _min=`echo $_min | sed -e '/\./s/0*$//' | sed -e 's/\.$//'` + _max=`echo $_max | sed -e '/\./s/0*$//' | sed -e 's/\.$//'`
I like Dave's suggestion to change it to the following, what do you think Eric?
+ _min=`echo $_min | sed -e '/\./s/0*$//' -e 's/\.$//'` # get rid of trailing zeros + _max=`echo $_max | sed -e '/\./s/0*$//' -e 's/\.$//'` # get rid of trailing zeros
Regards
--Rich
Quoted 4 lines
You can do this with a single sed invocation via multiple expressions:
Quoted 8 lines
$ echo 200.00 | sed -e '/\./s/0*$//' -e 's/\.$//' 200 $Cheers,
Dave.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 33 lines · Rich Johnston
Quoted 20 lines · Dave Chinner
Quoted 19 lines · Eric Whitney
_within_tolerancestrips trailing zeros from the min and max range values it outputs. This leads to damage if the min or max value is an integer containing trailing zeros rather than a real number with a fractional part containing trailing zeros. Xfstest 289 can exhibit this problem when its input is out of range. Modify the code so it will only remove trailing zeros found after a decimal point, and remove decimal points not followed by digits.Signed-off-by Eric Whitney <[email protected]>--- common.filter | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)common.filter +0
-0@@ -106,8 +106,11 @@ EOFQuoted 9 lines
common.filter EOF · line 113
Quoted 9 lines
common.filter +5
-2# fix up min, max precision for output # can vary for 5.3, 6.2 - _min=`echo $_min | sed -e 's/0*$//'` # get rid of trailling zeroes - _max=`echo $_max | sed -e 's/0*$//'` # get rid of trailling zeroes + + # remove any trailing zeroes from min, max if they have fractional parts + # and then remove any decimal points not followed by digits + _min=`echo $_min | sed -e '/\./s/0*$//' | sed -e 's/\.$//'` + _max=`echo $_max | sed -e '/\./s/0*$//' | sed -e 's/\.$//'`I like Dave's suggestion to change it to the following, what do you think Eric?
Review
Quoted 2 lines
(quoted diff) +2
-0+ _min=`echo $_min | sed -e '/\./s/0*$//' -e 's/\.$//'` # get rid of trailing zeros + _max=`echo $_max | sed -e '/\./s/0*$//' -e 's/\.$//'` # get rid of trailing zeros
looks awesome. Don't much care. Better to just fix than to dither for too long, aiming for the best sed ever ;)
-Eric
Quoted 17 lines
Regards
--RichQuoted 12 lines
You can do this with a single sed invocation via multiple expressions:
$ echo 200.00 | sed -e '/\./s/0*$//' -e 's/\.$//' 200 $Cheers,
Dave.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
* Rich Johnston <[email protected]>:
Quoted 21 lines · Dave Chinner
Quoted 20 lines · Eric Whitney
Quoted 19 lines
_within_tolerancestrips trailing zeros from the min and max range values it outputs. This leads to damage if the min or max value is an integer containing trailing zeros rather than a real number with a fractional part containing trailing zeros. Xfstest 289 can exhibit this problem when its input is out of range. Modify the code so it will only remove trailing zeros found after a decimal point, and remove decimal points not followed by digits.Signed-off-by Eric Whitney <[email protected]>--- common.filter | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)common.filter +0
-0@@ -106,8 +106,11 @@ EOF
Quoted 12 lines
Quoted 9 lines
common.filter EOF · line 113
Quoted 9 lines
common.filter +5
-2# fix up min, max precision for output # can vary for 5.3, 6.2 - _min=`echo $_min | sed -e 's/0*$//'` # get rid of trailling zeroes - _max=`echo $_max | sed -e 's/0*$//'` # get rid of trailling zeroes + + # remove any trailing zeroes from min, max if they have fractional parts + # and then remove any decimal points not followed by digits + _min=`echo $_min | sed -e '/\./s/0*$//' | sed -e 's/\.$//'` + _max=`echo $_max | sed -e '/\./s/0*$//' | sed -e 's/\.$//'`I like Dave's suggestion to change it to the following, what do you think Eric?
I just posted a V3 containing Dave's simplification. I'd hoped there would be something like that, and much appreciate the suggestion.
Thanks,
Eric
Quoted 23 lines
+ _min=
echo $_min | sed -e '/\./s/0*$//' -e 's/\.$//'# get rid of trailing zeros
+ _max=echo $_max | sed -e '/\./s/0*$//' -e 's/\.$//'# get rid of trailing zerosRegards
--RichQuoted 12 lines
You can do this with a single sed invocation via multiple expressions:
$ echo 200.00 | sed -e '/\./s/0*$//' -e 's/\.$//' 200 $Cheers,
Dave.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs