From 510c8ceff6e3da603b54cf9061f6efd777c66752 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 23 Jan 2011 14:48:16 +0200 Subject: Store option names as std::string instead of const char* With the scanner interface we now cannot assume that the returned value will still be valid after another call to more(). This was the case when we were always scanning argv/argc but now that we have the file scanner, we have to be careful. --- cli/runtime-source.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'cli/runtime-source.cxx') diff --git a/cli/runtime-source.cxx b/cli/runtime-source.cxx index 7f87d1f..37dc1ac 100644 --- a/cli/runtime-source.cxx +++ b/cli/runtime-source.cxx @@ -474,11 +474,11 @@ generate_runtime_source (context& ctx) << "static void" << endl << "parse (X& x, " << (sp ? "bool& xs, " : "") << "scanner& s)" << "{" - << "const char* o (s.next ());" + << "std::string o (s.next ());" << endl << "if (s.more ())" << "{" - << "const char* v (s.next ());" + << "std::string v (s.next ());" << "std::istringstream is (v);" << "if (!(is >> x && is.eof ()))" << endl << "throw invalid_value (o, v);" @@ -582,7 +582,7 @@ generate_runtime_source (context& ctx) << "parse (std::map& m, " << (sp ? "bool& xs, " : "") << "scanner& s)" << "{" - << "const char* o (s.next ());" + << "std::string o (s.next ());" << endl << "if (s.more ())" << "{" -- cgit v1.1