summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/control.sh35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/control.sh b/src/control.sh
index 6a92ff3..e73c842 100644
--- a/src/control.sh
+++ b/src/control.sh
@@ -43,7 +43,6 @@ parse_control()
local field_cb="${2}"
local paragraph_cb="${3}"
shift 3
- local check_fields=
local req_fields=
local line_nr=
local in_paragraph=
@@ -53,11 +52,9 @@ parse_control()
local name=
local value=
- check_fields='false'
if [ ${#} -eq 1 ]; then
- req_fields="${1}"
+ req_fields=" ${1} "
shift 1
- check_fields='true'
fi
line_nr=0
@@ -93,8 +90,8 @@ parse_control()
"${para_req_fields}"
fi
fi
- para_req_fields="$(printf '%s\n' ${req_fields})"
- got_fields="${LF}"
+ para_req_fields="${req_fields}"
+ got_fields=' '
name=''
value=''
;;
@@ -117,23 +114,23 @@ parse_control()
"${line_nr}" 'control_bad_nv'
continue
fi
- if [ -n "${para_req_fields}" ]; then
- # Remove field from list of required
- # fields.
- para_req_fields="$(printf '%s' \
- "${para_req_fields}" | \
- grep -Fv "${name}")"
- fi
- if [ "x${got_fields%${LF}${name}${LF}*}" != \
- "x${got_fields}" ]; then
+ case "${got_fields}" in *" ${name} "*)
# Duplicate field.
- _parse_control_error \
+ _ob_parse_control_error \
"${file}" "${line_nr}" \
'control_duplicate_field' \
"${name}"
- else
- got_fields="${got_fields}${name}${LF}"
- fi
+ continue
+ esac
+ got_fields="${got_fields}${name} "
+ case "${para_req_fields}" in *" ${name} "*)
+ # Required field: remove from list.
+ para_req_fields="$(:\
+ )${para_req_fields% ${name} *}$(
+ :\
+ ) ${para_req_fields#* ${name} }"
+ continue
+ esac
;;
' '*) # Continuation line.
in_paragraph='true'