base-files: ipcalc.sh: trim for statement
authorLeon M. George <leon@georgemail.eu>
Fri, 14 Oct 2022 12:08:19 +0000 (14:08 +0200)
committerChristian Marangi <ansuelsmth@gmail.com>
Tue, 7 Feb 2023 20:05:57 +0000 (21:05 +0100)
For gawk compatibility.

Signed-off-by: Leon M. George <leon@georgemail.eu>
package/base-files/files/bin/ipcalc.sh

index e818e678033266ec1d4be4105e152ff66d53e26d..99269fff066f99176ad5802d7005eb53e6e29fca 100755 (executable)
@@ -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
 }