s'assurer dans tous les contexte que l'on a bien un entier, pour éviter des erreurs de comparaisons

This commit is contained in:
Jephte CLAIN 2014-09-29 20:56:17 +04:00
parent b9fe0d47c3
commit e359998d09
1 changed files with 6 additions and 4 deletions

View File

@ -1715,6 +1715,7 @@ function array_new(dest) {
function array_newsize(dest, size, i) {
dest[0] = 0 # forcer awk à considérer dest comme un tableau
delete dest
size = int(size)
for (i = 1; i <= size; i++) {
dest[i] = ""
}
@ -1744,11 +1745,12 @@ function array_add(dest, value, lastindex) {
dest[lastindex + 1] = value
}
function array_deli(dest, i, l) {
i = int(i)
if (i == 0) return
l = length(dest)
while (i < l) {
dest[i] = dest[i + 1]
i = i + 1
i++
}
delete dest[l]
}
@ -1804,11 +1806,11 @@ function key_index(value, values, ignoreCase, i) {
if (ignoreCase) {
value = tolower(value)
for (i in values) {
if (tolower(values[i]) == value) return i
if (tolower(values[i]) == value) return int(i)
}
} else {
for (i in values) {
if (values[i] == value) return i
if (values[i] == value) return int(i)
}
}
return 0
@ -1823,7 +1825,7 @@ function array2s(values, prefix, sep, suffix, noindices, first, i, s) {
if (first) first = 0
else s = s sep
if (!noindices) s = s "[" i "]="
s = values[i]
s = s values[i]
}
s = s suffix
return s