summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorgstein <gstein@13f79535-47bb-0310-9956-ffa450edef68>2000-11-29 07:41:27 +0000
committergstein <gstein@13f79535-47bb-0310-9956-ffa450edef68>2000-11-29 07:41:27 +0000
commitf60e7ba649c374c3e4324c30025d22dc7c011dee (patch)
treed0b6635ef964ec2f4058fb9468d2bc1016d9be6c /misc
parentdf431f10b7d4ce0cc0824f04b20b987b722f4a4f (diff)
downloadlibapr-f60e7ba649c374c3e4324c30025d22dc7c011dee.tar.gz
Add an extra const into the getopt functions. We never attempt to modify any
of the data, so the const is proper. This also allows clients to pass const data in. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@60812 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'misc')
-rw-r--r--misc/unix/getopt.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/misc/unix/getopt.c b/misc/unix/getopt.c
index f74603aec..e27ff5ed2 100644
--- a/misc/unix/getopt.c
+++ b/misc/unix/getopt.c
@@ -49,10 +49,8 @@ static const char *pretty_path (const char *name)
}
APR_DECLARE(apr_status_t) apr_initopt(apr_getopt_t **os, apr_pool_t *cont,
- int argc, char *const *argv)
+ int argc, const char *const *argv)
{
- int i;
-
*os = apr_palloc(cont, sizeof(apr_getopt_t));
(*os)->cont = cont;
(*os)->err = 1;
@@ -64,19 +62,19 @@ APR_DECLARE(apr_status_t) apr_initopt(apr_getopt_t **os, apr_pool_t *cont,
want to use this function with arrays other than the main argv,
and we shouldn't touch the caller's data. So we copy. */
(*os)->argv = apr_palloc(cont, (argc + 1) * sizeof(const char *));
- for (i = 0; i < argc; i++)
- (*os)->argv[i] = argv[i];
+ memcpy((*os)->argv, argv, argc * sizeof(const char *));
(*os)->argv[argc] = NULL;
(*os)->interleave = 0;
(*os)->ind = 1;
(*os)->skip_start = 1;
(*os)->skip_end = 1;
+
return APR_SUCCESS;
}
APR_DECLARE(apr_status_t) apr_getopt(apr_getopt_t *os, const char *opts,
- char *optch, const char **optarg)
+ char *optch, const char **optarg)
{
const char *oli; /* option letter list index */