summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/control.sh25
-rw-r--r--lib/package/2.sh19
2 files changed, 23 insertions, 21 deletions
diff --git a/lib/control.sh b/lib/control.sh
index bf3e8fb..da48313 100644
--- a/lib/control.sh
+++ b/lib/control.sh
@@ -1,6 +1,6 @@
# Functions for parsing control files
#
-# Copyright (C) 2012, 2018 Patrick McDermott
+# Copyright (C) 2012, 2018, 2019 Patrick McDermott
#
# This file is part of opkbuild.
#
@@ -19,9 +19,6 @@
_OB_SUBSTVARS_MAX_DEPTH=50
-OB_CONTROL_NAME=
-OB_CONTROL_VALUE=
-
_ob_parse_control_error()
{
local file=
@@ -54,9 +51,8 @@ _ob_parse_control_error()
## @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.
-## For each field, \fBob_parse_control\fP calls \fIfield_cb\fP after
-## setting \fIOB_CONTROL_NAME\fP to the field name and
-## \fIOB_CONTROL_VALUE\fP to the field value. If \fIreq_fields\fP and
+## For each field, \fBob_parse_control\fP calls \fIfield_cb\fP with the
+## field name and value as arguments. If \fIreq_fields\fP and
## \fIopt_fields\fP are given, \fBob_parse_control\fP verifies that the
## input control file contains all fields listed in \fIreq_fields\fP
## and no fields that are listed in neither \fIreq_fields\fP nor
@@ -70,10 +66,9 @@ _ob_parse_control_error()
## @return Returns 0 after parsing, or 125 if called with an incorrect number of
## arguments.
## @stderr Prints error messages on parse errors.
-## @pure maybe This function sets global variables, but they're only intended
-## for use by \fIfield_cb\fP, which is called during the lifetime of
-## this function. Whether this function is subshell-safe in
-## practice depends on whether \fIfield_cb\fP is subshell-safe.
+## @pure maybe This function has no side effects. Whether this function is
+## subshell-safe in practice depends on whether \fIfield_cb\fP is
+## subshell-safe.
ob_parse_control()
{
local file=
@@ -118,9 +113,7 @@ ob_parse_control()
;;
[!\ ]*':'*) # "Name: Value" line.
if [ -n "${name}" ]; then
- OB_CONTROL_NAME="${name}"
- OB_CONTROL_VALUE="${value}"
- "${field_cb}"
+ "${field_cb}" "${name}" "${value}"
if [ ${?} -ne 0 ]; then
return 0
fi
@@ -172,9 +165,7 @@ ${line# }"
EOF
if [ -n "${name}" ]; then
- OB_CONTROL_NAME="${name}"
- OB_CONTROL_VALUE="${value}"
- "${field_cb}"
+ "${field_cb}" "${name}" "${value}"
if [ ${?} -ne 0 ]; then
return 0
fi
diff --git a/lib/package/2.sh b/lib/package/2.sh
index c1c37d5..4ca7346 100644
--- a/lib/package/2.sh
+++ b/lib/package/2.sh
@@ -69,7 +69,11 @@ _ob_get_binary_packages_2()
_ob_srcfield_2()
{
- _ob_set_source_parameter "${OB_CONTROL_NAME}" "${OB_CONTROL_VALUE}"
+ local name="${1}"
+ local value="${2}"
+ shift 2
+
+ _ob_set_source_parameter "${name}" "${value}"
return 0
}
@@ -89,8 +93,11 @@ _ob_change_2()
_ob_binfield_2()
{
- _ob_set_binary_parameter "${_OB_CURRENT_PACKAGE_2}" "${OB_CONTROL_NAME}" \
- "${OB_CONTROL_VALUE}"
+ local name="${1}"
+ local value="${2}"
+ shift 2
+
+ _ob_set_binary_parameter "${_OB_CURRENT_PACKAGE_2}" "${name}" "${value}"
return 0
}
@@ -163,7 +170,11 @@ _ob_set_package_substvars_2()
_ob_substvar_2()
{
- ob_set_substvar "${OB_CONTROL_NAME}" "${OB_CONTROL_VALUE}"
+ local name="${1}"
+ local value="${2}"
+ shift 2
+
+ ob_set_substvar "${name}" "${value}"
return 0
}