aboutsummaryrefslogtreecommitdiffstats
path: root/core/qthelper.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-01-07 11:12:48 +0100
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2018-01-11 06:07:13 +0100
commite85ecdd9254a8bd222ccb2dfed7d3b3bb96c8294 (patch)
tree0483cdb3c5770ca75eeeb0cc2de787b0e7bdbd3c /core/qthelper.cpp
parent86ef9fce7517313570838ca8e853132876035611 (diff)
downloadsubsurface-e85ecdd9254a8bd222ccb2dfed7d3b3bb96c8294.tar.gz
Introduce helper function empty_string()
There are ca. 50 constructs of the kind same_string(s, "") to test for empty or null strings. Replace them by the new helper function empty_string(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/qthelper.cpp')
-rw-r--r--core/qthelper.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/core/qthelper.cpp b/core/qthelper.cpp
index 058c2f253..6916b1a68 100644
--- a/core/qthelper.cpp
+++ b/core/qthelper.cpp
@@ -408,7 +408,7 @@ extern "C" void copy_image_and_overwrite(const char *cfileName, const char *path
extern "C" bool string_sequence_contains(const char *string_sequence, const char *text)
{
- if (same_string(text, "") || same_string(string_sequence, ""))
+ if (empty_string(text) || empty_string(string_sequence))
return false;
QString stringSequence(string_sequence);
@@ -525,7 +525,7 @@ QString uiLanguage(QLocale *callerLoc)
if (callerLoc)
*callerLoc = loc;
- if (!prefs.date_format_override || same_string(prefs.date_format_short, "") || same_string(prefs.date_format, "")) {
+ if (!prefs.date_format_override || empty_string(prefs.date_format_short) || empty_string(prefs.date_format)) {
// derive our standard date format from what the locale gives us
// the short format is fine
// the long format uses long weekday and month names, so replace those with the short ones
@@ -536,16 +536,16 @@ QString uiLanguage(QLocale *callerLoc)
// special hack for Swedish as our switching from long weekday names to short weekday names
// messes things up there
dateFormat.replace("'en' 'den' d:'e'", " d");
- if (!prefs.date_format_override || same_string(prefs.date_format, "")) {
+ if (!prefs.date_format_override || empty_string(prefs.date_format)) {
free((void *)prefs.date_format);
prefs.date_format = strdup(qPrintable(dateFormat));
}
- if (!prefs.date_format_override || same_string(prefs.date_format_short, "")) {
+ if (!prefs.date_format_override || empty_string(prefs.date_format_short)) {
free((void *)prefs.date_format_short);
prefs.date_format_short = strdup(qPrintable(shortDateFormat));
}
}
- if (!prefs.time_format_override || same_string(prefs.time_format, "")) {
+ if (!prefs.time_format_override || empty_string(prefs.time_format)) {
timeFormat = loc.timeFormat();
timeFormat.replace("(t)", "").replace(" t", "").replace("t", "").replace("hh", "h").replace("HH", "H").replace("'kl'.", "");
timeFormat.replace(".ss", "").replace(":ss", "").replace("ss", "");
@@ -1186,7 +1186,7 @@ void hashPicture(struct picture *picture)
return;
char *oldHash = copy_string(picture->hash);
learnHash(picture, hashFile(localFilePath(picture->filename)));
- if (!same_string(picture->hash, "") && !same_string(picture->hash, oldHash))
+ if (!empty_string(picture->hash) && !same_string(picture->hash, oldHash))
mark_divelist_changed((true));
free(oldHash);
picture_free(picture);
@@ -1430,7 +1430,7 @@ int getCloudURL(QString &filename)
{
QString email = QString(prefs.cloud_storage_email);
email.replace(QRegularExpression("[^a-zA-Z0-9@._+-]"), "");
- if (email.isEmpty() || same_string(prefs.cloud_storage_password, ""))
+ if (email.isEmpty() || empty_string(prefs.cloud_storage_password))
return report_error("Please configure Cloud storage email and password in the preferences");
if (email != prefs.cloud_storage_email_encoded) {
free((void *)prefs.cloud_storage_email_encoded);