diff mbox series

common/filter: Don't use strtonum

Message ID 20191129072108857.YEGH.25002.ppp.dion.ne.jp@dmta0003.auone-net.jp (mailing list archive)
State New, archived
Headers show
Series common/filter: Don't use strtonum | expand

Commit Message

Kusanagi Kouichi Nov. 29, 2019, 7:21 a.m. UTC
It's a gawk extension and not needed. Make tests pass with non-gawk.

Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
---
 common/filter | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

Comments

Eryu Guan Dec. 1, 2019, 3:47 p.m. UTC | #1
On Fri, Nov 29, 2019 at 04:21:08PM +0900, Kusanagi Kouichi wrote:
> It's a gawk extension and not needed. Make tests pass with non-gawk.
> 
> Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>

I noticed that you sent another two patches that fix similar issue in
another test. I think we could fold them into one patch that fixes all
the strtonum problem.

Thanks,
Eryu

> ---
>  common/filter | 23 +++++++++++++----------
>  1 file changed, 13 insertions(+), 10 deletions(-)
> 
> diff --git a/common/filter b/common/filter
> index 2477f386..e02cc0b9 100644
> --- a/common/filter
> +++ b/common/filter
> @@ -241,9 +241,9 @@ _filter_xfs_io_units_modified()
>  		/wrote/ {
>  			split($2, bytes, "/")
>  
> -			bytes_written = strtonum(bytes[1])
> +			bytes_written = bytes[1]
>  
> -			offset = strtonum($NF)
> +			offset = $NF
>  
>  			unit_start = offset / unit_size
>  			unit_start = int(unit_start)
> @@ -487,14 +487,17 @@ _filter_busy_mount()
>  _filter_od()
>  {
>  	BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT)
> -	$AWK_PROG -v block_size=$BLOCK_SIZE '
> -		/^[0-9]+/ {
> -			offset = strtonum("0"$1);
> -			$1 = sprintf("%o", offset / block_size);
> -			print $0;
> -		}
> -		/\*/
> -	'
> +	while read line
> +	do
> +		if test "$line" = '*'
> +		then
> +			printf '*\n'
> +			continue
> +		fi
> +
> +		offset="${line%% *}"
> +		printf '%o%s\n' $((offset / BLOCK_SIZE)) "${line#$offset}"
> +	done
>  }
>  
>  # Remove quotes from failed mknod calls. Starting with Coreutils v8.25,
> -- 
> 2.24.0
>
Kusanagi Kouichi Dec. 2, 2019, 9:34 a.m. UTC | #2
On 2019-12-01 23:47:47 +0800, Eryu Guan wrote:
> On Fri, Nov 29, 2019 at 04:21:08PM +0900, Kusanagi Kouichi wrote:
> > It's a gawk extension and not needed. Make tests pass with non-gawk.
> > 
> > Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
> 
> I noticed that you sent another two patches that fix similar issue in
> another test. I think we could fold them into one patch that fixes all
> the strtonum problem.
> 
> Thanks,
> Eryu

I'll fold them into this patch and resend.
diff mbox series

Patch

diff --git a/common/filter b/common/filter
index 2477f386..e02cc0b9 100644
--- a/common/filter
+++ b/common/filter
@@ -241,9 +241,9 @@  _filter_xfs_io_units_modified()
 		/wrote/ {
 			split($2, bytes, "/")
 
-			bytes_written = strtonum(bytes[1])
+			bytes_written = bytes[1]
 
-			offset = strtonum($NF)
+			offset = $NF
 
 			unit_start = offset / unit_size
 			unit_start = int(unit_start)
@@ -487,14 +487,17 @@  _filter_busy_mount()
 _filter_od()
 {
 	BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT)
-	$AWK_PROG -v block_size=$BLOCK_SIZE '
-		/^[0-9]+/ {
-			offset = strtonum("0"$1);
-			$1 = sprintf("%o", offset / block_size);
-			print $0;
-		}
-		/\*/
-	'
+	while read line
+	do
+		if test "$line" = '*'
+		then
+			printf '*\n'
+			continue
+		fi
+
+		offset="${line%% *}"
+		printf '%o%s\n' $((offset / BLOCK_SIZE)) "${line#$offset}"
+	done
 }
 
 # Remove quotes from failed mknod calls. Starting with Coreutils v8.25,