[openwrt/openwrt] base-files: ipcalc.sh: trim for statement

LEDE Commits lede-commits at lists.infradead.org
Tue Feb 7 12:09:38 PST 2023


ansuel pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/2903924b576c19ab64490917ec46cb3bee790ad2

commit 2903924b576c19ab64490917ec46cb3bee790ad2
Author: Leon M. George <leon at georgemail.eu>
AuthorDate: Fri Oct 14 14:08:19 2022 +0200

    base-files: ipcalc.sh: trim for statement
    
    For gawk compatibility.
    
    Signed-off-by: Leon M. George <leon at georgemail.eu>
---
 package/base-files/files/bin/ipcalc.sh | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/package/base-files/files/bin/ipcalc.sh b/package/base-files/files/bin/ipcalc.sh
index e818e67803..99269fff06 100755
--- a/package/base-files/files/bin/ipcalc.sh
+++ b/package/base-files/files/bin/ipcalc.sh
@@ -10,14 +10,20 @@ function bitcount(c) {
 }
 
 function ip2int(ip) {
-	for (ret=0,n=split(ip,a,"\."),x=1;x<=n;x++) ret=or(lshift(ret,8),a[x])
+	ret=0
+	n=split(ip,a,"\.")
+	for (x=1;x<=n;x++)
+		ret=or(lshift(ret,8),a[x])
 	return ret
 }
 
 function int2ip(ip,ret,x) {
 	ret=and(ip,255)
 	ip=rshift(ip,8)
-	for(;x<3;ret=and(ip,255)"."ret,ip=rshift(ip,8),x++);
+	for(;x<3;x++) {
+		ret=and(ip,255)"."ret
+		ip=rshift(ip,8)
+	}
 	return ret
 }
 




More information about the lede-commits mailing list