1
0
mirror of https://git.openwrt.org/openwrt/openwrt.git synced 2024-10-18 13:29:16 +02:00

base-files: ipcalc.sh: trim for statement

For gawk compatibility.

Signed-off-by: Leon M. George <leon@georgemail.eu>
This commit is contained in:
Leon M. George 2022-10-14 14:08:19 +02:00 committed by Christian Marangi
parent e4bd3de1be
commit 2903924b57
No known key found for this signature in database
GPG Key ID: AC001D09ADBFEAD7

@ -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
}