diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 3d45c46ce8..81a5bf02f0 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -357,7 +357,8 @@ public: template void foreach_route (void (Route::*method)(A), A arg); template void foreach_route (void (Route::*method)(A1, A2), A1 arg1, A2 arg2); - static char session_name_is_legal (const std::string&); + static const std::string session_name_is_legal (const std::string&); + bool io_name_is_legal (const std::string&) const; boost::shared_ptr route_by_name (std::string) const; boost::shared_ptr route_by_id (PBD::ID) const; diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc index 5d6c774cc3..fa963fefbd 100644 --- a/libs/ardour/midi_region.cc +++ b/libs/ardour/midi_region.cc @@ -828,7 +828,7 @@ MidiRegion::set_name (const std::string& str) return true; } - if (Session::session_name_is_legal (str) != 0) { + if (!Session::session_name_is_legal (str).empty ()) { return false; } diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index b0c65463ab..8a3b86ed4f 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -6760,18 +6760,23 @@ Session::update_latency_compensation (bool force_whole_graph, bool called_from_b DEBUG_TRACE (DEBUG::LatencyCompensation, "update_latency_compensation: complete\n"); } -char +const std::string Session::session_name_is_legal (const string& path) { - char illegal_chars[] = { '/', '\\', ':', ';', '\0' }; + char illegal_chars[] = { '/', '\\', ':', ';' }; for (int i = 0; illegal_chars[i]; ++i) { if (path.find (illegal_chars[i]) != string::npos) { - return illegal_chars[i]; + return std::string (1, illegal_chars[i]); } } - return 0; + for (size_t i = 0; i < path.length(); ++i) { + if (iscntrl (path[i])) { + return _("Control Char"); + } + } + return std::string (); } void diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index 7998a9d611..c153c50acc 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -2933,9 +2933,9 @@ OSC::name_session (char *n, lo_message msg) return -1; } string new_name = n; - char illegal = Session::session_name_is_legal (new_name); + std::string const& illegal = Session::session_name_is_legal (new_name); - if (illegal) { + if (!illegal.empty()) { PBD::warning << (string_compose (_("To ensure compatibility with various systems\n" "session names may not contain a '%1' character"), illegal)) << endmsg; return -1;