__ini_value: change empty value check
Change the short-circuit check for an empty value to a more structual approach. This might be better for the code or not ..
This commit is contained in:
parent
ad736a66d0
commit
46638f0839
1 changed files with 38 additions and 41 deletions
|
@ -66,56 +66,53 @@ found {print; next}
|
||||||
# main loop (til the line was found)
|
# main loop (til the line was found)
|
||||||
!found {
|
!found {
|
||||||
line = trim($0)
|
line = trim($0)
|
||||||
# short curcit on empty lines
|
# process if the line is not empty (or only contains spaces)
|
||||||
if(line == "") {
|
if(line != "") {
|
||||||
push_line()
|
# check for a ini section
|
||||||
next
|
if(substr(line, 1, 1) == "[" && substr(line, length(line), 1) == "]") {
|
||||||
}
|
is_section = 1
|
||||||
|
curr_section = line
|
||||||
|
|
||||||
# check for a ini section
|
if(curr_section == section) {
|
||||||
if(substr(line, 1, 1) == "[" && substr(line, length(line), 1) == "]") {
|
found_section = 1
|
||||||
is_section = 1
|
is_curr_section = 1
|
||||||
curr_section = line
|
}
|
||||||
|
else {
|
||||||
|
# if nothing found, print it in the valid section before the next one
|
||||||
|
if(is_curr_section) {
|
||||||
|
if(!found) {
|
||||||
|
# set found as it is there now
|
||||||
|
found=1
|
||||||
|
|
||||||
if(curr_section == section) {
|
# %codeblock_insert%
|
||||||
found_section = 1
|
|
||||||
is_curr_section = 1
|
# print line as it would else only be populated below
|
||||||
|
print
|
||||||
|
next
|
||||||
|
}
|
||||||
|
is_curr_section = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# if nothing found, print it in the valid section before the next one
|
# only current session is interessting
|
||||||
if(is_curr_section) {
|
if(is_curr_section) {
|
||||||
if(!found) {
|
# check for a comment
|
||||||
# set found as it is there now
|
is_com = is_comment(line)
|
||||||
found=1
|
if(is_com) {
|
||||||
|
line = trim(substr(line, 2))
|
||||||
# %codeblock_insert%
|
|
||||||
|
|
||||||
# print line as it would else only be populated below
|
|
||||||
print
|
|
||||||
next
|
|
||||||
}
|
}
|
||||||
is_curr_section = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
# only current session is interessting
|
|
||||||
if(is_curr_section) {
|
|
||||||
# check for a comment
|
|
||||||
is_com = is_comment(line)
|
|
||||||
if(is_com) {
|
|
||||||
line = trim(substr(line, 2))
|
|
||||||
}
|
|
||||||
|
|
||||||
# check for a delimiter and a key (must be at first position due to trimming)
|
# check for a delimiter and a key (must be at first position due to trimming)
|
||||||
if((idel = index(line, delimiter)) && (ikey = index(line, key)) == 1) {
|
if((idel = index(line, delimiter)) && (ikey = index(line, key)) == 1) {
|
||||||
# check there are only spaces between the key and delimiter
|
# check there are only spaces between the key and delimiter
|
||||||
if(check_spaces(substr(line, ikey + length(key), idel - (length(key) + 1)))) {
|
if(check_spaces(substr(line, ikey + length(key), idel - (length(key) + 1)))) {
|
||||||
found = 1
|
found = 1
|
||||||
|
|
||||||
# %codeblock_found%
|
# %codeblock_found%
|
||||||
|
|
||||||
next
|
next
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue