From ecd4c8cc17419bf894017e1026f1ebcbb40dec47 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Thu, 21 May 2009 23:51:56 +0200 Subject: [PATCH] get rid of C style casts --- src/browser.cpp | 2 +- src/charset.cpp | 4 ++-- src/mpdpp.h | 2 +- src/ncmpcpp.cpp | 18 +++++++++--------- src/search_engine.cpp | 4 ++-- src/settings.cpp | 2 +- src/status.cpp | 2 +- src/window.cpp | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/browser.cpp b/src/browser.cpp index 94bbde5a..cfb1813c 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -416,7 +416,7 @@ void Browser::GetDirectory(string dir, string subdir) { Item parent; size_t slash = dir.rfind("/"); - parent.song = (Song *) 1; // in that way we assume that's really parent dir + parent.song = reinterpret_cast(1); // in that way we assume that's really parent dir parent.name = slash != string::npos ? dir.substr(0, slash) : "/"; parent.type = itDirectory; utf_to_locale(parent.name); diff --git a/src/charset.cpp b/src/charset.cpp index 7f4474f6..fd62e7b9 100644 --- a/src/charset.cpp +++ b/src/charset.cpp @@ -62,7 +62,7 @@ namespace iconv_t cd = iconv_open(to, from); - if (cd == (iconv_t)-1) + if (cd == iconv_t(-1)) return; if (!len) @@ -72,7 +72,7 @@ namespace char *outstart = outbuf; char *instart = inbuf; - if (iconv(cd, const_cast(&inbuf), &len, &outbuf, &buflen) == (size_t)-1) + if (iconv(cd, const_cast(&inbuf), &len, &outbuf, &buflen) == size_t(-1)) { delete [] outstart; iconv_close(cd); diff --git a/src/mpdpp.h b/src/mpdpp.h index d31b0e00..3cbb0750 100644 --- a/src/mpdpp.h +++ b/src/mpdpp.h @@ -115,7 +115,7 @@ namespace MPD void Shuffle() const; void ClearPlaylist() const; - PlayerState GetState() const { return isConnected && itsCurrentStatus ? (PlayerState)itsCurrentStatus->state : psUnknown; } + PlayerState GetState() const { return isConnected && itsCurrentStatus ? PlayerState(itsCurrentStatus->state) : psUnknown; } bool GetRepeat() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->repeat : 0; } bool GetRandom() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->random : 0; } bool GetSingle() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->single : 0; } diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 36f9e99c..9f389850 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -223,17 +223,17 @@ int main(int argc, char *argv[]) else { *wHeader << XY(0, 0) - << fmtBold << (char)Key.Help[0] << fmtBoldEnd << ":Help " - << fmtBold << (char)Key.Playlist[0] << fmtBoldEnd << ":Playlist " - << fmtBold << (char)Key.Browser[0] << fmtBoldEnd << ":Browse " - << fmtBold << (char)Key.SearchEngine[0] << fmtBoldEnd << ":Search " - << fmtBold << (char)Key.MediaLibrary[0] << fmtBoldEnd << ":Library " - << fmtBold << (char)Key.PlaylistEditor[0] << fmtBoldEnd << ":Playlist editor"; + << fmtBold << char(Key.Help[0]) << fmtBoldEnd << ":Help " + << fmtBold << char(Key.Playlist[0]) << fmtBoldEnd << ":Playlist " + << fmtBold << char(Key.Browser[0]) << fmtBoldEnd << ":Browse " + << fmtBold << char(Key.SearchEngine[0]) << fmtBoldEnd << ":Search " + << fmtBold << char(Key.MediaLibrary[0]) << fmtBoldEnd << ":Library " + << fmtBold << char(Key.PlaylistEditor[0]) << fmtBoldEnd << ":Playlist editor"; # ifdef HAVE_TAGLIB_H - *wHeader << " " << fmtBold << (char)Key.TagEditor[0] << fmtBoldEnd << ":Tag editor"; + *wHeader << " " << fmtBold << char(Key.TagEditor[0]) << fmtBoldEnd << ":Tag editor"; # endif // HAVE_TAGLIB_H # ifdef ENABLE_CLOCK - *wHeader << " " << fmtBold << (char)Key.Clock[0] << fmtBoldEnd << ":Clock"; + *wHeader << " " << fmtBold << char(Key.Clock[0]) << fmtBoldEnd << ":Clock"; # endif // ENABLE_CLOCK } @@ -985,7 +985,7 @@ int main(int argc, char *argv[]) wFooter->Bold(1); string tracklength = "[" + Song::ShowTime(songpos) + "/" + s->GetLength() + "]"; *wFooter << XY(wFooter->GetWidth()-tracklength.length(), 1) << tracklength; - double progressbar_size = (double)songpos/(s->GetTotalLength()); + double progressbar_size = songpos/double(s->GetTotalLength()); int howlong = wFooter->GetWidth()*progressbar_size; mvwhline(wFooter->Raw(), 0, 0, 0, wFooter->GetWidth()); diff --git a/src/search_engine.cpp b/src/search_engine.cpp index b36c0944..ea9bd514 100644 --- a/src/search_engine.cpp +++ b/src/search_engine.cpp @@ -196,7 +196,7 @@ void SearchEngine::EnterPressed() size_t found = w->Size()-SearchEngine::StaticOptions; found += 3; // don't count options inserted below w->InsertSeparator(ResetButton+1); - w->InsertOption(ResetButton+2, std::make_pair((Buffer *)0, (Song *)0), 1, 1); + w->InsertOption(ResetButton+2, std::make_pair(static_cast(0), static_cast(0)), 1, 1); w->at(ResetButton+2).first = new Buffer(); *w->at(ResetButton+2).first << Config.color1 << "Search results: " << Config.color2 << "Found " << found << (found > 1 ? " songs" : " song") << clDefault; w->InsertSeparator(ResetButton+3); @@ -599,7 +599,7 @@ void SearchEngine::Search() if (found && any_found) { Song *ss = Config.search_in_db ? *it : new Song(**it); - w->AddOption(std::make_pair((Buffer *)0, ss)); + w->AddOption(std::make_pair(static_cast(0), ss)); list[it-list.begin()] = 0; } found = 1; diff --git a/src/settings.cpp b/src/settings.cpp index 1bac1560..beedb7bc 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -75,7 +75,7 @@ namespace Border IntoBorder(const string &color) { - return (Border) IntoColor(color); + return Border(IntoColor(color)); } } diff --git a/src/status.cpp b/src/status.cpp index c5366c08..5916477c 100644 --- a/src/status.cpp +++ b/src/status.cpp @@ -408,7 +408,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *) } if (!block_progressbar_update) { - double progressbar_size = (double)elapsed/(np.GetTotalLength()); + double progressbar_size = elapsed/double(np.GetTotalLength()); int howlong = wFooter->GetWidth()*progressbar_size; wFooter->SetColor(Config.progressbar_color); mvwhline(wFooter->Raw(), 0, 0, 0, wFooter->GetWidth()); diff --git a/src/window.cpp b/src/window.cpp index 5f1c5d77..8155211e 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -558,7 +558,7 @@ string Window::GetString(const string &base, size_t length, size_t width, bool e break; tmp_in += input; - if ((int)mbrtowc(&wc_in, tmp_in.c_str(), MB_CUR_MAX, 0) < 0) + if (int(mbrtowc(&wc_in, tmp_in.c_str(), MB_CUR_MAX, 0)) < 0) break; if (wcwidth(wc_in) > 1)