__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)
|
||||
!found {
|
||||
line = trim($0)
|
||||
# short curcit on empty lines
|
||||
if(line == "") {
|
||||
push_line()
|
||||
next
|
||||
}
|
||||
# process if the line is not empty (or only contains spaces)
|
||||
if(line != "") {
|
||||
# check for a ini section
|
||||
if(substr(line, 1, 1) == "[" && substr(line, length(line), 1) == "]") {
|
||||
is_section = 1
|
||||
curr_section = line
|
||||
|
||||
# check for a ini section
|
||||
if(substr(line, 1, 1) == "[" && substr(line, length(line), 1) == "]") {
|
||||
is_section = 1
|
||||
curr_section = line
|
||||
if(curr_section == section) {
|
||||
found_section = 1
|
||||
is_curr_section = 1
|
||||
}
|
||||
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) {
|
||||
found_section = 1
|
||||
is_curr_section = 1
|
||||
# %codeblock_insert%
|
||||
|
||||
# print line as it would else only be populated below
|
||||
print
|
||||
next
|
||||
}
|
||||
is_curr_section = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
# if nothing found, print it in the valid section before the next one
|
||||
# only current session is interessting
|
||||
if(is_curr_section) {
|
||||
if(!found) {
|
||||
# set found as it is there now
|
||||
found=1
|
||||
|
||||
# %codeblock_insert%
|
||||
|
||||
# print line as it would else only be populated below
|
||||
print
|
||||
next
|
||||
# check for a comment
|
||||
is_com = is_comment(line)
|
||||
if(is_com) {
|
||||
line = trim(substr(line, 2))
|
||||
}
|
||||
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)
|
||||
if((idel = index(line, delimiter)) && (ikey = index(line, key)) == 1) {
|
||||
# check there are only spaces between the key and delimiter
|
||||
if(check_spaces(substr(line, ikey + length(key), idel - (length(key) + 1)))) {
|
||||
found = 1
|
||||
# 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) {
|
||||
# check there are only spaces between the key and delimiter
|
||||
if(check_spaces(substr(line, ikey + length(key), idel - (length(key) + 1)))) {
|
||||
found = 1
|
||||
|
||||
# %codeblock_found%
|
||||
# %codeblock_found%
|
||||
|
||||
next
|
||||
next
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue