Skip to contentSkip to conversation

xfstests: don't remove trailing zeros from integers

PATCH In review Eric Whitney 3 participants 3 messages Mar 5, 2013

lore
Share & tools
lore
#0 lore raw

PATCH v3 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.

V1->V2: Remove decimal points not followed by digits V2->V3: Per Dave Chinner, simplify by using multiple sed expressions

---
 common.filter |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
common.filter +4 -2
index 9e4c90c..c854a98 100644
@@ -106,8 +106,10 @@ 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
+  _min=`echo $_min | sed -e '/\./s/0*$//' -e 's/\.$//'`
+  _max=`echo $_max | sed -e '/\./s/0*$//' -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
Reviewed-by on v3 1/1
#1 lore raw
Quoted 11 lines · Eric Whitney

_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.

V1->V2: Remove decimal points not followed by digits V2->V3: Per Dave Chinner, simplify by using multiple sed expressions

Quoted 12 lines
---
 common.filter |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
common.filter +0 -0
index 9e4c90c..c854a98 100644
@@ -106,8 +106,10 @@ EOF
 
   # fix up min, max precision for output

common.filter EOF · line 115

Quoted 10 lines
common.filter +4 -2
   # 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
+  _min=`echo $_min | sed -e '/\./s/0*$//' -e 's/\.$//'`
+  _max=`echo $_max | sed -e '/\./s/0*$//' -e 's/\.$//'`
 
   if [ $_in_range -eq 1 ] 
   then

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Reviewed-by Eric Sandeen on v3 1/1
#2 lore raw
In reply to Eric Whitney

This patch has been committed.

Thanks
--Rich

commit edce9e677fda49ca20d6059248937ab4af65d053

Author: Eric Whitney <[email protected]>
Date:   Tue Mar 5 19:17:48 2013 +0000

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.

V1->V2: Remove decimal points not followed by digits V2->V3: Per Dave Chinner, simplify by using multiple sed expressions

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs