along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id$
*/
#include <cstdio> /* for sprintf */
#include <cmath>
#include <cctype>
-#include <string>
+#include <cstring>
#include <cerrno>
#include <iostream>
#include <sys/types.h>
ustring::size_type pos;
ustring legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_+=: ";
ustring legal;
-
+
legal = str;
pos = 0;
return legal;
}
-#if 0
-string
-legalize_for_path (string str)
+
+string bump_name_once(std::string name)
{
- string::size_type pos;
- string legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_+=: ";
- string legal;
+ string::size_type period;
+ string newname;
- legal = str;
- pos = 0;
+ if ((period = name.find_last_of ('.')) == string::npos) {
+ newname = name;
+ newname += ".1";
+ } else {
+ int isnumber = 1;
+ const char *last_element = name.c_str() + period + 1;
+ for (size_t i = 0; i < strlen(last_element); i++) {
+ if (!isdigit(last_element[i])) {
+ isnumber = 0;
+ break;
+ }
+ }
- while ((pos = legal.find_first_not_of (legal_chars, pos)) != string::npos) {
- legal.replace (pos, 1, "_");
- pos += 1;
+ errno = 0;
+ long int version = strtol (name.c_str()+period+1, (char **)NULL, 10);
+
+ if (isnumber == 0 || errno != 0) {
+ // last_element is not a number, or is too large
+ newname = name;
+ newname += ".1";
+ } else {
+ char buf[32];
+
+ snprintf (buf, sizeof(buf), "%ld", version+1);
+
+ newname = name.substr (0, period+1);
+ newname += buf;
+ }
}
- return legal;
+ return newname;
+
}
-#endif
ostream&
operator<< (ostream& o, const BBT_Time& bbt)
}
ustring
-region_name_from_path (ustring path, bool strip_channels)
+region_name_from_path (ustring path, bool strip_channels, bool add_channel_suffix, uint32_t total, uint32_t this_one)
{
path = PBD::basename_nosuffix (path);
}
}
+ if (add_channel_suffix) {
+
+ path += '%';
+
+ if (total > 2) {
+ path += (char) ('a' + this_one);
+ } else {
+ path += (char) (this_one == 0 ? 'L' : 'R');
+ }
+ }
+
return path;
}
{
double step;
- step = 1.0/nframes;
+ step = 1.0/(nframes-1);
in[0] = 0.0f;
return Splice;
} else if (str == _("Slide Edit")) {
return Slide;
+ } else if (str == _("Lock Edit")) {
+ return Lock;
}
fatal << string_compose (_("programming error: unknown edit mode string \"%1\""), str) << endmsg;
/*NOTREACHED*/
case Slide:
return _("Slide Edit");
+ case Lock:
+ return _("Lock Edit");
+
default:
case Splice:
return _("Splice Edit");
return "";
}
+bool
+string_is_affirmative (const std::string& str)
+{
+ /* to be used only with XML data - not intended to handle user input */
+
+ return str == "1" || str == "y" || str == "Y" || (!g_strncasecmp(str.c_str(), "yes", str.length()));
+}
+
extern "C" {
void c_stacktrace() { stacktrace (cerr); }
}