From 4a304bf34e443b7bae353e992a5ca55aa36aa6a6 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 16 Jan 2018 10:17:09 +0100 Subject: [PATCH] util/OptionParser: make string pointers "const" --- src/util/OptionParser.cxx | 2 +- src/util/OptionParser.hxx | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/util/OptionParser.cxx b/src/util/OptionParser.cxx index 1c4e42ef5..4cc1acb16 100644 --- a/src/util/OptionParser.cxx +++ b/src/util/OptionParser.cxx @@ -40,7 +40,7 @@ bool OptionParser::ParseNext() noexcept { assert(HasEntries()); - char *arg = *argv; + const char *arg = *argv; ++argv; --argc; if (arg[0] == '-') { diff --git a/src/util/OptionParser.hxx b/src/util/OptionParser.hxx index 06ca6ba7a..e8dd5de60 100644 --- a/src/util/OptionParser.hxx +++ b/src/util/OptionParser.hxx @@ -30,16 +30,16 @@ class OptionDef; class OptionParser { int argc; - char **argv; - char *option = nullptr; - char *option_raw = nullptr; + char *const*argv; + const char *option = nullptr; + const char *option_raw = nullptr; bool is_long = false; public: /** * Constructs #OptionParser. */ - constexpr OptionParser(int _argc, char **_argv) noexcept + constexpr OptionParser(int _argc, char *const*_argv) noexcept :argc(_argc - 1), argv(_argv + 1) {} /** @@ -52,7 +52,7 @@ public: /** * Gets the last parsed option. */ - char *GetOption() noexcept { + const char *GetOption() noexcept { assert(option_raw != nullptr); return option_raw; }