Skip to content

Commit

Permalink
Style fix: compare to 0 in strcmp() explicitly.
Browse files Browse the repository at this point in the history
  • Loading branch information
jscipione committed Dec 5, 2012
1 parent 2005db2 commit cfd9c96
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
22 changes: 11 additions & 11 deletions src/apps/terminal/AppearPrefView.cpp
Expand Up @@ -225,8 +225,8 @@ AppearancePrefView::AttachedToWindow()

_SetCurrentColorScheme(fColorSchemeField);
bool enableCustomColors =
!strcmp(fColorSchemeField->Menu()->FindMarked()->Label(),
gCustomColorScheme.name);
strcmp(fColorSchemeField->Menu()->FindMarked()->Label(),
gCustomColorScheme.name) == 0;

_EnableCustomColors(enableCustomColors);
}
Expand All @@ -250,18 +250,18 @@ AppearancePrefView::MessageReceived(BMessage* msg)
= pref->getString(PREF_HALF_FONT_FAMILY);
const char* currentStyle
= pref->getString(PREF_HALF_FONT_STYLE);
if (currentFamily == NULL || strcmp(currentFamily, family)
|| currentStyle == NULL || strcmp(currentStyle, style)) {
if (currentFamily == NULL || strcmp(currentFamily, family) != 0
|| currentStyle == NULL || strcmp(currentStyle, style) != 0) {
pref->setString(PREF_HALF_FONT_FAMILY, family);
pref->setString(PREF_HALF_FONT_STYLE, style);
modified = true;
}
break;
}

case MSG_HALF_SIZE_CHANGED:
if (strcmp(PrefHandler::Default()->getString(PREF_HALF_FONT_SIZE),
fFontSize->Menu()->FindMarked()->Label())) {

fFontSize->Menu()->FindMarked()->Label()) != 0) {
PrefHandler::Default()->setString(PREF_HALF_FONT_SIZE,
fFontSize->Menu()->FindMarked()->Label());
modified = true;
Expand Down Expand Up @@ -405,7 +405,7 @@ AppearancePrefView::_SetCurrentColorScheme(BMenuField* field)

for (int32 i = 0; i < fColorSchemeField->Menu()->CountItems(); i++) {
BMenuItem* item = fColorSchemeField->Menu()->ItemAt(i);
if (!strcmp(item->Label(), currentSchemeName)) {
if (strcmp(item->Label(), currentSchemeName) == 0) {
item->SetMarked(true);
break;
}
Expand Down Expand Up @@ -440,8 +440,8 @@ AppearancePrefView::_MakeFontMenu(uint32 command,
BMenuItem* item = new BMenuItem(itemLabel,
message);
menu->AddItem(item);
if (!strcmp(defaultFamily, family)
&& !strcmp(defaultStyle, style))
if (strcmp(defaultFamily, family) == 0
&& strcmp(defaultStyle, style) == 0)
item->SetMarked(true);
}
}
Expand Down Expand Up @@ -502,7 +502,7 @@ AppearancePrefView::_MakeMenu(uint32 msg, const char** items,

int32 i = 0;
while (*items) {
if (!strcmp((*items), ""))
if (strcmp((*items), "") == 0)
menu->AddSeparatorItem();
else {
BMessage* message = new BMessage(msg);
Expand All @@ -529,7 +529,7 @@ AppearancePrefView::_MakeColorSchemeMenu(uint32 msg, const color_scheme** items,

int32 i = 0;
while (*items) {
if (!strcmp((*items)->name, ""))
if (strcmp((*items)->name, "") == 0)
menu->AddSeparatorItem();
else {
BMessage* message = new BMessage(msg);
Expand Down
4 changes: 2 additions & 2 deletions src/apps/terminal/PrefHandler.cpp
Expand Up @@ -242,7 +242,7 @@ PrefHandler::getBool(const char *key)
if (value == NULL)
return false;

return !strcmp(value, PREF_TRUE);
return strcmp(value, PREF_TRUE) == 0;
}


Expand Down Expand Up @@ -352,7 +352,7 @@ PrefHandler::_ConfirmFont(const char *key, const BFont *fallback)
if (get_font_family(i, &family) != B_OK)
continue;

if (!strcmp(family, font)) {
if (strcmp(family, font) == 0) {
// found font family: we can safely use this font
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/apps/terminal/TermApp.cpp
Expand Up @@ -200,7 +200,7 @@ TermApp::RefsReceived(BMessage* message)
info.GetType(mimetype);

// if App opened by Pref file
if (!strcmp(mimetype, PREFFILE_MIMETYPE)) {
if (strcmp(mimetype, PREFFILE_MIMETYPE) == 0) {

BEntry ent(&ref);
BPath path(&ent);
Expand All @@ -209,7 +209,7 @@ TermApp::RefsReceived(BMessage* message)
}

// if App opened by Shell Script
if (!strcmp(mimetype, "text/x-haiku-shscript")){
if (strcmp(mimetype, "text/x-haiku-shscript") == 0) {
// Not implemented.
// beep();
return;
Expand Down
9 changes: 6 additions & 3 deletions src/apps/terminal/TermView.cpp
Expand Up @@ -1862,7 +1862,8 @@ TermView::MessageReceived(BMessage *msg)
int32 encodingID;
BMessage specifier;
if (msg->GetCurrentSpecifier(&i, &specifier) == B_OK
&& !strcmp("encoding", specifier.FindString("property", i))) {
&& !strcmp("encoding",
specifier.FindString("property", i)) == 0) {
msg->FindInt32 ("data", &encodingID);
SetEncoding(encodingID);
msg->SendReply(B_REPLY);
Expand All @@ -1877,11 +1878,13 @@ TermView::MessageReceived(BMessage *msg)
int32 i;
BMessage specifier;
if (msg->GetCurrentSpecifier(&i, &specifier) == B_OK
&& !strcmp("encoding", specifier.FindString("property", i))) {
&& strcmp("encoding",
specifier.FindString("property", i)) == 0) {
BMessage reply(B_REPLY);
reply.AddInt32("result", Encoding());
msg->SendReply(&reply);
} else if (!strcmp("tty", specifier.FindString("property", i))) {
} else if (strcmp("tty",
specifier.FindString("property", i)) == 0) {
BMessage reply(B_REPLY);
reply.AddString("result", TerminalName());
msg->SendReply(&reply);
Expand Down

0 comments on commit cfd9c96

Please sign in to comment.