length(array) ne fonctionne pas dans certains cas sur gawk 3.1.5
réimplémenter sous la forme de array_len() pour corriger ce bug
This commit is contained in:
parent
6be3597698
commit
305f9e821a
|
@ -1 +1 @@
|
|||
003003000
|
||||
003004000
|
||||
|
|
|
@ -1720,6 +1720,15 @@ function array_newsize(dest, size, i) {
|
|||
dest[i] = ""
|
||||
}
|
||||
}
|
||||
function array_len(values, count, i) {
|
||||
# length(array) a un bug sur awk 3.1.5
|
||||
# cette version est plus lente mais fonctionne toujours
|
||||
count = 0
|
||||
for (i in values) {
|
||||
count++
|
||||
}
|
||||
return count
|
||||
}
|
||||
function mkindices(values, indices, i, j) {
|
||||
array_new(indices)
|
||||
j = 1
|
||||
|
@ -1747,7 +1756,7 @@ function array_add(dest, value, lastindex) {
|
|||
function array_deli(dest, i, l) {
|
||||
i = int(i)
|
||||
if (i == 0) return
|
||||
l = length(dest)
|
||||
l = array_len(dest)
|
||||
while (i < l) {
|
||||
dest[i] = dest[i + 1]
|
||||
i++
|
||||
|
@ -1986,11 +1995,11 @@ function __array_parsecsv(fields, line, nbfields, colsep, qchar, echar, shou
|
|||
i = i + 1
|
||||
}
|
||||
if (nbfields) {
|
||||
while (length(fields) < nbfields) {
|
||||
fields[length(fields) + 1] = ""
|
||||
while (array_len(fields) < nbfields) {
|
||||
fields[array_len(fields) + 1] = ""
|
||||
}
|
||||
}
|
||||
return length(fields)
|
||||
return array_len(fields)
|
||||
}
|
||||
BEGIN {
|
||||
DEFAULT_COLSEP = ","
|
||||
|
@ -2076,8 +2085,8 @@ function array_findcsv(fields, input, field, value, nbfields, orig, fou
|
|||
if (!found) {
|
||||
delete fields
|
||||
if (nbfields) {
|
||||
while (length(fields) < nbfields) {
|
||||
fields[length(fields) + 1] = ""
|
||||
while (array_len(fields) < nbfields) {
|
||||
fields[array_len(fields) + 1] = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue