Fix compile with bad strrchr signature

This commit is contained in:
Christian Kamm 2017-09-19 12:44:59 +02:00 committed by Roeland Jago Douma
parent 2cac928810
commit 6161b5519b
No known key found for this signature in database
GPG key ID: F941078878347C0C

View file

@ -46,6 +46,7 @@
#include <math.h> #include <math.h>
#include <stdarg.h> #include <stdarg.h>
#include <cstring>
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
#include "utility_win.cpp" #include "utility_win.cpp"
@ -547,28 +548,28 @@ QUrl Utility::concatUrlPath(const QUrl &url, const QString &concatPath,
bool Utility::isConflictFile(const char *name) bool Utility::isConflictFile(const char *name)
{ {
auto bname = strrchr(name, '/'); const char *bname = std::strrchr(name, '/');
if (bname) { if (bname) {
bname += 1; bname += 1;
} else { } else {
bname = name; bname = name;
} }
if (strstr(bname, "_conflict-")) if (std::strstr(bname, "_conflict-"))
return true; return true;
if (shouldUploadConflictFiles()) { if (shouldUploadConflictFiles()) {
// For uploads, we want to consider files with any kind of username tag // For uploads, we want to consider files with any kind of username tag
// as conflict files. (pattern *_conflict_*-) // as conflict files. (pattern *_conflict_*-)
auto startOfMarker = strstr(bname, "_conflict_"); const char *startOfMarker = std::strstr(bname, "_conflict_");
if (startOfMarker && strchr(startOfMarker, '-')) if (startOfMarker && std::strchr(startOfMarker, '-'))
return true; return true;
} else { } else {
// Old behavior: optionally, files with the specific string in the env variable // Old behavior: optionally, files with the specific string in the env variable
// appended are also considered conflict files. // appended are also considered conflict files.
static auto conflictFileUsername = qgetenv("CSYNC_CONFLICT_FILE_USERNAME"); static auto conflictFileUsername = qgetenv("CSYNC_CONFLICT_FILE_USERNAME");
static auto usernameConflictId = QByteArray("_conflict_" + conflictFileUsername + "-"); static auto usernameConflictId = QByteArray("_conflict_" + conflictFileUsername + "-");
if (!conflictFileUsername.isEmpty() && strstr(bname, usernameConflictId.constData())) { if (!conflictFileUsername.isEmpty() && std::strstr(bname, usernameConflictId.constData())) {
return true; return true;
} }
} }