modernize std::string("foo") into "foo"s

* spot/ltsmin/ltsmin.cc, spot/misc/tmpfile.cc,
spot/parseaut/parseaut.yy, spot/taalgos/dot.cc, spot/tl/hierarchy.cc,
spot/tl/unabbrev.cc, spot/twa/acc.cc, spot/twa/twagraph.cc,
spot/twaalgos/dot.cc, spot/twaalgos/hoa.cc, spot/twaalgos/lbtt.cc,
spot/twaalgos/neverclaim.cc, spot/twaalgos/strength.cc,
spot/twaalgos/word.cc: Replace std::string("foo") by "foo"s, and
include namespace std::string_literals.
This commit is contained in:
Alexandre Duret-Lutz 2018-07-19 11:02:47 +02:00
parent 832ee81f75
commit d08193508e
14 changed files with 66 additions and 51 deletions

View file

@ -38,6 +38,8 @@
#include <spot/misc/intvcomp.hh> #include <spot/misc/intvcomp.hh>
#include <spot/misc/intvcmp2.hh> #include <spot/misc/intvcmp2.hh>
using namespace std::string_literals;
namespace spot namespace spot
{ {
namespace namespace
@ -972,15 +974,15 @@ namespace spot
} }
else else
{ {
throw std::runtime_error(std::string("Unknown extension '") throw std::runtime_error("Unknown extension '"s + ext +
+ ext + "'. Use '.prom', '.pm', '.pml', " "'. Use '.prom', '.pm', '.pml', "
"'.dve', '.dve2C', '.gal', '.gal2C' or " "'.dve', '.dve2C', '.gal', '.gal2C' or "
"'.prom.spins'."); "'.prom.spins'.");
} }
struct stat s; struct stat s;
if (stat(filename.c_str(), &s) != 0) if (stat(filename.c_str(), &s) != 0)
throw std::runtime_error(std::string("Cannot open ") + filename); throw std::runtime_error("Cannot open "s + filename);
filename += compiled_ext; filename += compiled_ext;
@ -998,7 +1000,7 @@ namespace spot
int res = system(command.c_str()); int res = system(command.c_str());
if (res) if (res)
throw std::runtime_error(std::string("Execution of '") throw std::runtime_error("Execution of '"s
+ command.c_str() + "' returned exit code " + command.c_str() + "' returned exit code "
+ std::to_string(WEXITSTATUS(res))); + std::to_string(WEXITSTATUS(res)));
} }
@ -1029,7 +1031,7 @@ namespace spot
{ {
std::string lt_error = lt_dlerror(); std::string lt_error = lt_dlerror();
lt_dlexit(); lt_dlexit();
throw std::runtime_error(std::string("Failed to load '") throw std::runtime_error("Failed to load '"s
+ file + "'.\n" + lt_error); + file + "'.\n" + lt_error);
} }
@ -1046,7 +1048,7 @@ namespace spot
// assume they can for POSIX). // assume they can for POSIX).
*reinterpret_cast<void**>(dst) = lt_dlsym(h, name); *reinterpret_cast<void**>(dst) = lt_dlsym(h, name);
if (dst == nullptr) if (dst == nullptr)
throw std::runtime_error(std::string("Failed to resolve symbol '") throw std::runtime_error("Failed to resolve symbol '"s
+ name + "' in '" + file + "'."); + name + "' in '" + file + "'.");
}; };

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*- // -*- coding: utf-8 -*-
// Copyright (C) 2013, 2015, 2017 Laboratoire de Recherche et // Copyright (C) 2013, 2015, 2017, 2018 Laboratoire de Recherche et
// Développement de l'Epita (LRDE). // Développement de l'Epita (LRDE).
// //
// This file is part of Spot, a model checking library. // This file is part of Spot, a model checking library.
@ -24,6 +24,8 @@
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
using namespace std::string_literals;
namespace spot namespace spot
{ {
namespace namespace
@ -73,7 +75,7 @@ namespace spot
fd = mkstemp(*name); fd = mkstemp(*name);
} }
if (fd < 0) if (fd < 0)
throw std::runtime_error(std::string("failed to create ") + *name); throw std::runtime_error("failed to create "s + *name);
return fd; return fd;
} }
} }
@ -109,7 +111,7 @@ namespace spot
if (fd_ < 0) if (fd_ < 0)
return; return;
if (::close(fd_)) if (::close(fd_))
throw std::runtime_error(std::string("failed to close ") + name_); throw std::runtime_error("failed to close "s + name_);
fd_ = -1; fd_ = -1;
} }
@ -119,7 +121,7 @@ namespace spot
char* name; char* name;
int fd = create_temporary_file(prefix, suffix, &name); int fd = create_temporary_file(prefix, suffix, &name);
if (close(fd)) if (close(fd))
throw std::runtime_error(std::string("failed to close ") + name); throw std::runtime_error("failed to close "s + name);
auto cp = to_clean.insert(to_clean.end(), nullptr); auto cp = to_clean.insert(to_clean.end(), nullptr);
*cp = new temporary_file(name, cp); *cp = new temporary_file(name, cp);
return *cp; return *cp;

View file

@ -43,6 +43,8 @@
#include <spot/tl/parse.hh> #include <spot/tl/parse.hh>
#include <spot/twaalgos/alternation.hh> #include <spot/twaalgos/alternation.hh>
using namespace std::string_literals;
#ifndef HAVE_STRVERSCMP #ifndef HAVE_STRVERSCMP
// If the libc does not have this, a version is compiled in lib/. // If the libc does not have this, a version is compiled in lib/.
extern "C" int strverscmp(const char *s1, const char *s2); extern "C" int strverscmp(const char *s1, const char *s2);
@ -877,11 +879,10 @@ properties: | properties IDENTIFIER
if (pos.first->second.val != val) if (pos.first->second.val != val)
{ {
std::ostringstream out(std::ios_base::ate); std::ostringstream out(std::ios_base::ate);
error(@2, std::string("'properties: ") error(@2, "'properties: "s + (val ? "" : "!")
+ (val ? "" : "!") + *$2 + "' contradicts..."); + *$2 + "' contradicts...");
error(pos.first->second.loc, error(pos.first->second.loc,
std::string("... 'properties: ") "... 'properties: "s + (val ? "!" : "") + *$2
+ (val ? "!" : "") + *$2
+ "' previously given here."); + "' previously given here.");
} }
delete $2; delete $2;
@ -894,11 +895,9 @@ properties: | properties IDENTIFIER
if (pos.first->second.val) if (pos.first->second.val)
{ {
std::ostringstream out(std::ios_base::ate); std::ostringstream out(std::ios_base::ate);
error(loc, std::string("'properties: !") error(loc, "'properties: !"s + *$3 + "' contradicts...");
+ *$3 + "' contradicts..."); error(pos.first->second.loc, "... 'properties: "s + *$3
error(pos.first->second.loc, + "' previously given here.");
std::string("... 'properties: ") + *$3
+ "' previously given here.");
} }
delete $3; delete $3;
} }
@ -1058,7 +1057,7 @@ acceptance-cond: IDENTIFIER '(' acc-set ')'
} }
else else
{ {
error(@1, std::string("unknown acceptance '") + *$1 error(@1, "unknown acceptance '"s + *$1
+ "', expected Fin or Inf"); + "', expected Fin or Inf");
$$ = new spot::acc_cond::acc_code; $$ = new spot::acc_cond::acc_code;
} }
@ -1837,9 +1836,8 @@ nc-one-ident: IDENTIFIER ':'
auto r = res.labels.insert(std::make_pair(*$1, @1)); auto r = res.labels.insert(std::make_pair(*$1, @1));
if (!r.second) if (!r.second)
{ {
error(@1, std::string("redefinition of ") + *$1 + "..."); error(@1, "redefinition of "s + *$1 + "...");
error(r.first->second, std::string("... ") + *$1 error(r.first->second, "... "s + *$1 + " previously defined here");
+ " previously defined here");
} }
$$ = $1; $$ = $1;
} }
@ -2507,7 +2505,7 @@ namespace spot
: filename_(name), opts_(opt) : filename_(name), opts_(opt)
{ {
if (hoayyopen(name, &scanner_)) if (hoayyopen(name, &scanner_))
throw std::runtime_error(std::string("Cannot open file ") + name); throw std::runtime_error("Cannot open file "s + name);
} }
catch (...) catch (...)
{ {
@ -2522,7 +2520,7 @@ namespace spot
: filename_(name), opts_(opt) : filename_(name), opts_(opt)
{ {
if (hoayyopen(fd, &scanner_)) if (hoayyopen(fd, &scanner_))
throw std::runtime_error(std::string("Cannot open file ") + name); throw std::runtime_error("Cannot open file "s + name);
} }
catch (...) catch (...)
{ {

View file

@ -27,6 +27,8 @@
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
using namespace std::string_literals;
namespace spot namespace spot
{ {
namespace namespace
@ -55,7 +57,7 @@ namespace spot
// Prevent infinite recursions... // Prevent infinite recursions...
if (orig == def.c_str()) if (orig == def.c_str())
throw std::runtime_error throw std::runtime_error
(std::string("SPOT_DOTDEFAULT should not contain '.'")); ("SPOT_DOTDEFAULT should not contain '.'");
if (!def.empty()) if (!def.empty())
parse_opts(def.c_str()); parse_opts(def.c_str());
break; break;
@ -85,12 +87,12 @@ namespace spot
case 'f': case 'f':
if (*options != '(') if (*options != '(')
throw std::runtime_error throw std::runtime_error
(std::string("invalid font specification for dotty()")); ("invalid font specification for dotty()");
{ {
auto* end = strchr(++options, ')'); auto* end = strchr(++options, ')');
if (!end) if (!end)
throw std::runtime_error throw std::runtime_error
(std::string("invalid font specification for dotty()")); ("invalid font specification for dotty()");
opt_font_ = std::string(options, end - options); opt_font_ = std::string(options, end - options);
options = end + 1; options = end + 1;
} }
@ -128,8 +130,7 @@ namespace spot
// SPOT_DEFAULT would be annoying. // SPOT_DEFAULT would be annoying.
break; break;
default: default:
throw std::runtime_error throw std::runtime_error("unknown option for dotty(): "s + c);
(std::string("unknown option for dotty(): ") + c);
} }
} }

View file

@ -32,6 +32,7 @@
#include <spot/twaalgos/totgba.hh> #include <spot/twaalgos/totgba.hh>
#include <spot/twaalgos/cobuchi.hh> #include <spot/twaalgos/cobuchi.hh>
using namespace std::string_literals;
namespace spot namespace spot
{ {
@ -460,7 +461,7 @@ namespace spot
goto break2; goto break2;
default: default:
throw std::runtime_error throw std::runtime_error
(std::string("nesting_depth(): unknown operator '") + c + '\''); ("nesting_depth(): unknown operator '"s + c + '\'');
} }
break2: break2:
if (want_nnf) if (want_nnf)

View file

@ -21,6 +21,8 @@
#include "config.h" #include "config.h"
#include <spot/tl/unabbrev.hh> #include <spot/tl/unabbrev.hh>
using namespace std::string_literals;
namespace spot namespace spot
{ {
unabbreviator::unabbreviator(const char* opt) unabbreviator::unabbreviator(const char* opt)
@ -61,9 +63,7 @@ namespace spot
re_some_bool_ = true; re_some_bool_ = true;
break; break;
default: default:
throw std::runtime_error throw std::runtime_error("unknown unabbreviation option: "s + c);
(std::string("unknown unabbreviation option: ")
+ c);
} }
} }

View file

@ -30,6 +30,8 @@
#include <spot/misc/minato.hh> #include <spot/misc/minato.hh>
#include <spot/misc/random.hh> #include <spot/misc/random.hh>
using namespace std::string_literals;
namespace spot namespace spot
{ {
void acc_cond::report_too_many_sets() void acc_cond::report_too_many_sets()
@ -1654,7 +1656,7 @@ namespace spot
break; break;
default: default:
throw std::runtime_error throw std::runtime_error
(std::string("unknown option for acc_cond::name(): ") + c); ("unknown option for acc_cond::name(): "s + c);
} }
std::ostringstream os; std::ostringstream os;

View file

@ -26,6 +26,8 @@
#include <vector> #include <vector>
#include <deque> #include <deque>
using namespace std::string_literals;
namespace spot namespace spot
{ {
@ -791,9 +793,8 @@ namespace spot
want_properties = true; want_properties = true;
break; break;
default: default:
throw std::runtime_error(std::string("dump_storage_as_dow(): " throw std::runtime_error
"unsupported option '") ("dump_storage_as_dow(): unsupported option '"s + opt[-1] +"'");
+ opt[-1] +"'");
} }
} }

View file

@ -39,6 +39,7 @@
#include <ctype.h> #include <ctype.h>
#include <utility> #include <utility>
using namespace std::string_literals;
namespace spot namespace spot
{ {
@ -176,7 +177,7 @@ namespace spot
// Prevent infinite recursions... // Prevent infinite recursions...
if (orig == def.c_str()) if (orig == def.c_str())
throw std::runtime_error throw std::runtime_error
(std::string("SPOT_DOTDEFAULT should not contain '.'")); ("SPOT_DOTDEFAULT should not contain '.'");
if (!def.empty()) if (!def.empty())
parse_opts(def.c_str()); parse_opts(def.c_str());
break; break;
@ -312,7 +313,7 @@ namespace spot
break; break;
default: default:
throw std::runtime_error throw std::runtime_error
(std::string("unknown option for print_dot(): ") + c); ("unknown option for print_dot(): "s + c);
} }
if (opt_color_sets_ && !opt_latex_) if (opt_color_sets_ && !opt_latex_)
opt_html_labels_ = true; opt_html_labels_ = true;

View file

@ -32,6 +32,8 @@
#include <spot/tl/formula.hh> #include <spot/tl/formula.hh>
#include <spot/kripke/fairkripke.hh> #include <spot/kripke/fairkripke.hh>
using namespace std::string_literals;
namespace spot namespace spot
{ {
namespace namespace
@ -318,8 +320,7 @@ namespace spot
verbose = true; verbose = true;
break; break;
default: default:
throw std::runtime_error throw std::runtime_error("unknown option for print_hoa(): "s + c);
(std::string("unknown option for print_hoa(): ") + c);
} }
} }

View file

@ -31,6 +31,8 @@
#include "spot/priv/accmap.hh" #include "spot/priv/accmap.hh"
#include <spot/tl/print.hh> #include <spot/tl/print.hh>
using namespace std::string_literals;
namespace spot namespace spot
{ {
namespace namespace
@ -142,8 +144,7 @@ namespace spot
sba = false; sba = false;
break; break;
default: default:
throw std::runtime_error throw std::runtime_error("unknown option for print_lbtt(): "s + c);
(std::string("unknown option for print_lbtt(): ") + c);
} }
lbtt_bfs b(g, os, sba); lbtt_bfs b(g, os, sba);

View file

@ -29,6 +29,8 @@
#include <spot/tl/print.hh> #include <spot/tl/print.hh>
#include <spot/twa/formula2bdd.hh> #include <spot/twa/formula2bdd.hh>
using namespace std::string_literals;
namespace spot namespace spot
{ {
namespace namespace
@ -61,8 +63,7 @@ namespace spot
break; break;
default: default:
throw std::runtime_error throw std::runtime_error
(std::string("unknown option for print_never_claim(): ") ("unknown option for print_never_claim(): "s + c);
+ c);
} }
} }

View file

@ -23,6 +23,8 @@
#include <spot/twaalgos/isweakscc.hh> #include <spot/twaalgos/isweakscc.hh>
#include <spot/twaalgos/mask.hh> #include <spot/twaalgos/mask.hh>
using namespace std::string_literals;
namespace spot namespace spot
{ {
namespace namespace
@ -206,7 +208,7 @@ namespace spot
{ {
if (keep_opt == nullptr || *keep_opt == 0) if (keep_opt == nullptr || *keep_opt == 0)
throw std::runtime_error throw std::runtime_error
(std::string("option for decompose_scc() should not be empty")); ("option for decompose_scc() should not be empty");
enum strength { enum strength {
Ignore = 0, Ignore = 0,
@ -247,7 +249,7 @@ namespace spot
if ((long unsigned) scc >= n) if ((long unsigned) scc >= n)
{ {
throw std::runtime_error throw std::runtime_error
(std::string("decompose_scc(): there is no SCC ") ("decompose_scc(): there is no SCC "s
+ std::to_string(scc) + " in this automaton"); + std::to_string(scc) + " in this automaton");
} }
keep_opt = endptr; keep_opt = endptr;
@ -272,7 +274,7 @@ namespace spot
if (j != scc + 1) if (j != scc + 1)
{ {
throw std::runtime_error throw std::runtime_error
(std::string("decompose_scc(): there is no SCC 'a") ("decompose_scc(): there is no SCC 'a"s
+ std::to_string(scc) + "' in this automaton"); + std::to_string(scc) + "' in this automaton");
} }
keep_opt = endptr; keep_opt = endptr;
@ -289,7 +291,7 @@ namespace spot
break; break;
default: default:
throw std::runtime_error throw std::runtime_error
(std::string("unknown option for decompose_scc(): ") + c); ("unknown option for decompose_scc(): "s + c);
} }
auto p = aut->acc().unsat_mark(); auto p = aut->acc().unsat_mark();

View file

@ -25,6 +25,8 @@
#include <spot/tl/simplify.hh> #include <spot/tl/simplify.hh>
#include <spot/tl/apcollect.hh> #include <spot/tl/apcollect.hh>
using namespace std::string_literals;
namespace spot namespace spot
{ {
twa_word::twa_word(const twa_run_ptr& run) twa_word::twa_word(const twa_run_ptr& run)
@ -185,7 +187,7 @@ namespace spot
}; };
// Parse the prefix part. Can be empty. // Parse the prefix part. Can be empty.
while (word.substr(i, 6) != std::string("cycle{")) while (word.substr(i, 6) != "cycle{"s)
{ {
ind = skip_next_formula(word, i); ind = skip_next_formula(word, i);
if (ind == std::string::npos) if (ind == std::string::npos)