correction bug sur les tableaux, et ajout de la possibi...
...lité de démarrer un tableau...
... | ... |
@@ -64,12 +64,16 @@ BEGIN { |
64 | 64 |
var_delimiters_end = "}}}" |
65 | 65 |
key_value_delimiter = "" |
66 | 66 |
in_var_space_remplacement = "" |
67 |
+ first_element_index = 0 |
|
67 | 68 |
|
68 | 69 |
for (arg = 1; arg < ARGC; arg++) |
69 | 70 |
switch (ARGV[arg]) { |
70 | 71 |
case /^--conf=["']?.+["']?$/: |
71 | 72 |
filename = gensub(/^--conf=["']?(.+)["']?$/, "\\1", "", ARGV[arg]) |
72 | 73 |
break |
74 |
+ case /^--conf$/: |
|
75 |
+ filename = gensub(/^["']?(.+)["']?$/, "\\1", "", ARGV[++arg]) |
|
76 |
+ break |
|
73 | 77 |
case "--sections-list": |
74 | 78 |
returnsectionlist = 1 |
75 | 79 |
break |
... | ... |
@@ -91,7 +95,12 @@ BEGIN { |
91 | 95 |
eol = ";" |
92 | 96 |
break |
93 | 97 |
case /^--array=["']?.+["']?$/: |
94 |
- conf_arrays = conf_arrays "|" gensub(/^--array=["']?(.+)["']?$/, "\\1", "", ARGV[arg]) |
|
98 |
+ arrayname=gensub(/^--array=["']?(.+)["']?$/, "\\1", "", ARGV[arg]) |
|
99 |
+ conf_arrays = conf_arrays "|" arrayname |
|
100 |
+ key_array[arrayname]++ |
|
101 |
+ break |
|
102 |
+ case /^--first-element-array=[01]$/: |
|
103 |
+ first_element_index = gensub(/^--first-element-array=([01])$/, "\\1", "", ARGV[arg]) |
|
95 | 104 |
break |
96 | 105 |
case /^--var-delim-begin=["']?.{3,}["']?$/: |
97 | 106 |
var_delimiters_begin = gensub(/^--var-delim-begin=["']?(.{3,})["']?$/, "\\1", "", ARGV[arg]) |
... | ... |
@@ -145,7 +154,7 @@ BEGIN { |
145 | 154 |
if (/^\s*\[.+\]\s*$/) { |
146 | 155 |
name=gensub(/^\s*\[(.+)\]\s*$/, "\\1", "g") |
147 | 156 |
for (key in key_array) |
148 |
- ptr[name][key_array[key]] = 0 |
|
157 |
+ ptr[name][key] = first_element_index |
|
149 | 158 |
continue |
150 | 159 |
} |
151 | 160 |
|
... | ... |
@@ -161,8 +170,8 @@ BEGIN { |
161 | 170 |
value = clean ? "" : gensub("^[[:blank:]]*" $1 "[[:blank:]]*", "", "") |
162 | 171 |
} |
163 | 172 |
key = apply_case_sensivity(key) |
164 |
- if (key ~ "^(" conf_arrays ")$" && ! unset) |
|
165 |
- conf[name][key][++ptr[name][key]] = value |
|
173 |
+ if (key ~ "^(" conf_arrays ")$" && ! unset) |
|
174 |
+ conf[name][key][ptr[name][key]++] = value |
|
166 | 175 |
else |
167 | 176 |
conf[name][key] = value |
168 | 177 |
} |
... | ... |
@@ -175,7 +184,7 @@ BEGIN { |
175 | 184 |
else for (name in onlysections) |
176 | 185 |
for (key in conf[name]) { |
177 | 186 |
if (key ~ "^(" conf_arrays ")$" && ! unset) |
178 |
- for (i=1; i<=ptr[name][key]; i++) |
|
187 |
+ for (i=first_element_index; i<ptr[name][key]; i++) |
|
179 | 188 |
printf("%s[%i]=%s", key, i, evaluate(conf[name][key][i]) eol) |
180 | 189 |
|
181 | 190 |
else { |