From 324d60d600ca10596acbca84a791fe16dc74b166 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Mon, 11 Mar 2019 17:50:01 -0400 Subject: Revert "ob_parse_control(): Run parse error callback" This reverts commit d80290a2f8c9f069261da78afd2f275e84923d0f. --- (limited to 'lib') diff --git a/lib/control.sh b/lib/control.sh index c5ed645..30c6b9c 100644 --- a/lib/control.sh +++ b/lib/control.sh @@ -19,6 +19,35 @@ _OB_SUBSTVARS_MAX_DEPTH=50 +_ob_parse_control_error() +{ + local file= + local line_nr= + local msg_id= + local file_info= + local orig_text_domain= + + file="${1}" + line_nr="${2}" + msg_id="${3}" + shift 3 + + if [ ${line_nr} -eq 0 ]; then + file_info="$(printf '%20s:' "${file}")" + else + file_info="$(printf '%20s(l%d):' "${file}" "${line_nr}")" + fi + + orig_text_domain="$(ob_get_text_domain)" + ob_set_text_domain "${_OB_INTERNAL_TEXT_DOMAIN}" + + ob_warn "${file_info} $(ob_get_msg "${msg_id}")" "${@}" + + ob_set_text_domain "${orig_text_domain}" + + return 0 +} + ## @brief Parse a control file ## @details \fBob_parse_control\fP parses a control file of field names and ## values formatted like RFC 822 (or RFC 2822 or RFC 5322) headers. @@ -84,7 +113,7 @@ ob_parse_control() line_nr=$(($line_nr + 1)) case "${line}" in '') - _ob_run_parse_error_cb "${file}" "${line_nr}" \ + _ob_parse_control_error "${file}" "${line_nr}" \ 'control_empty_line' ;; '#'*) # Comment. @@ -100,7 +129,7 @@ ob_parse_control() EOF if [ -z "${name}" ]; then # Badly formatted control field. - _ob_run_parse_error_cb "${file}" "${line_nr}" \ + _ob_parse_control_error "${file}" "${line_nr}" \ 'control_bad_nv' continue fi @@ -108,7 +137,7 @@ ob_parse_control() if [ "${all_fields% ${name} *}" = \ "${all_fields}" ]; then # Unknown field. - _ob_run_parse_error_cb \ + _ob_parse_control_error \ "${file}" "${line_nr}" \ 'control_unknown_field' "${name}" else @@ -120,7 +149,7 @@ ob_parse_control() if [ "${got_fields% ${name} *}" != \ "${got_fields}" ]; then # Duplicate field. - _ob_run_parse_error_cb "${file}" "${line_nr}" \ + _ob_parse_control_error "${file}" "${line_nr}" \ 'control_duplicate_field' "${name}" else got_fields="${got_fields}${name} " @@ -129,7 +158,7 @@ ob_parse_control() ' '*) # Continuation line. if [ -z "${name}" ]; then # Expecting a "Name: Value" line. - _ob_run_parse_error_cb "${file}" "${line_nr}" \ + _ob_parse_control_error "${file}" "${line_nr}" \ 'control_found_continuation' continue fi @@ -153,7 +182,7 @@ ob_parse_control() # Missing required control fields. req_fields="$(echo "${req_fields}" | sed 's/ / /g' | \ sed "s/ /$(ob_get_msg 'list_item_separator')/g")" - _ob_run_parse_error_cb "${file}" '0' \ + _ob_parse_control_error "${file}" '0' \ 'control_missing_fields' "${req_fields}" fi fi -- cgit v0.9.1