Simplify string comparison

This is based on Linus' idea on the mailing list.
Treat NULL strings and empty strings as identical.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-05-06 14:08:17 -07:00
parent 024420a60d
commit 0c836ebc47
3 changed files with 12 additions and 15 deletions

View file

@ -856,12 +856,11 @@ void MainTab::rejectChanges()
// this macro is rather fragile and is intended to be used as WHAT inside
// an invocation of EDIT_SELECTED_DIVES(WHAT)
#define EDIT_TEXT(what, text) \
if ((!mydive->what && !current_dive->what) || \
(mydive->what && current_dive->what && strcmp(mydive->what, current_dive->what) == 0)) { \
QByteArray textByteArray = text.toUtf8(); \
free(mydive->what); \
mydive->what = strdup(textByteArray.data()); \
#define EDIT_TEXT(what, text) \
if (same_string(mydive->what, current_dive->what)) { \
QByteArray textByteArray = text.toUtf8(); \
free(mydive->what); \
mydive->what = strdup(textByteArray.data()); \
}
#define EDIT_VALUE(what, value) \