mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
024420a60d
commit
0c836ebc47
3 changed files with 12 additions and 15 deletions
|
@ -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) \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue