Browse Source

Replaced NULL with nullptr wherever applicable.

merge-requests/365/head
nshcat 10 years ago
parent
commit
da33a926a4
  1. 2
      src/config.cc
  2. 10
      src/debug_lldb.cc
  3. 4
      src/dialogs.cc
  4. 14
      src/git.cc
  5. 4
      src/notebook.cc
  6. 8
      src/project.cc
  7. 4
      src/selectiondialog.cc
  8. 12
      src/source.cc
  9. 6
      src/source_clang.cc
  10. 20
      src/source_spellcheck.cc
  11. 4
      src/terminal.cc
  12. 4
      src/window.cc

2
src/config.cc

@ -28,7 +28,7 @@ Config::Config() {
#ifdef _WIN32 #ifdef _WIN32
auto env_MSYSTEM_PREFIX=std::getenv("MSYSTEM_PREFIX"); auto env_MSYSTEM_PREFIX=std::getenv("MSYSTEM_PREFIX");
if(env_MSYSTEM_PREFIX!=NULL) if(env_MSYSTEM_PREFIX!=nullptr)
terminal.msys2_mingw_path=boost::filesystem::path(env_MSYSTEM_PREFIX); terminal.msys2_mingw_path=boost::filesystem::path(env_MSYSTEM_PREFIX);
#endif #endif
} }

10
src/debug_lldb.cc

@ -80,7 +80,7 @@ void Debug::LLDB::start(const std::string &command, const boost::filesystem::pat
const char *argv[arguments.size()+1]; const char *argv[arguments.size()+1];
for(size_t c=0;c<arguments.size();c++) for(size_t c=0;c<arguments.size();c++)
argv[c]=arguments[c].c_str(); argv[c]=arguments[c].c_str();
argv[arguments.size()]=NULL; argv[arguments.size()]=nullptr;
auto target=debugger->CreateTarget(executable.c_str()); auto target=debugger->CreateTarget(executable.c_str());
if(!target.IsValid()) { if(!target.IsValid()) {
@ -310,11 +310,11 @@ std::vector<Debug::LLDB::Frame> Debug::LLDB::get_backtrace() {
backtrace_frame.index=c_f; backtrace_frame.index=c_f;
if(frame.GetFunctionName()!=NULL) if(frame.GetFunctionName()!=nullptr)
backtrace_frame.function_name=frame.GetFunctionName(); backtrace_frame.function_name=frame.GetFunctionName();
auto module_filename=frame.GetModule().GetFileSpec().GetFilename(); auto module_filename=frame.GetModule().GetFileSpec().GetFilename();
if(module_filename!=NULL) { if(module_filename!=nullptr) {
backtrace_frame.module_filename=module_filename; backtrace_frame.module_filename=module_filename;
} }
@ -351,7 +351,7 @@ std::vector<Debug::LLDB::Variable> Debug::LLDB::get_variables() {
Debug::LLDB::Variable variable; Debug::LLDB::Variable variable;
variable.thread_index_id=thread.GetIndexID(); variable.thread_index_id=thread.GetIndexID();
variable.frame_index=c_f; variable.frame_index=c_f;
if(value.GetName()!=NULL) if(value.GetName()!=nullptr)
variable.name=value.GetName(); variable.name=value.GetName();
value.GetDescription(stream); value.GetDescription(stream);
variable.value=stream.GetData(); variable.value=stream.GetData();
@ -417,7 +417,7 @@ std::string Debug::LLDB::get_value(const std::string &variable, const boost::fil
lldb::SBStream stream; lldb::SBStream stream;
auto value=values.GetValueAtIndex(value_index); auto value=values.GetValueAtIndex(value_index);
if(value.GetName()!=NULL && value.GetName()==variable) { if(value.GetName()!=nullptr && value.GetName()==variable) {
auto declaration=value.GetDeclaration(); auto declaration=value.GetDeclaration();
if(declaration.IsValid()) { if(declaration.IsValid()) {
if(declaration.GetLine()==line_nr && (declaration.GetColumn()==0 || declaration.GetColumn()==line_index)) { if(declaration.GetLine()==line_nr && (declaration.GetColumn()==0 || declaration.GetColumn()==line_index)) {

4
src/dialogs.cc

@ -24,8 +24,8 @@ Dialog::Message::Message(const std::string &text): Gtk::MessageDialog(text, fals
show_now(); show_now();
while(g_main_context_pending(NULL)) while(g_main_context_pending(nullptr))
g_main_context_iteration(NULL, false); g_main_context_iteration(nullptr, false);
} }
bool Dialog::Message::on_delete_event(GdkEventAny *event) { bool Dialog::Message::on_delete_event(GdkEventAny *event) {

14
src/git.cc

@ -8,7 +8,7 @@ std::mutex Git::repositories_mutex;
std::string Git::Error::message() noexcept { std::string Git::Error::message() noexcept {
const git_error *last_error = giterr_last(); const git_error *last_error = giterr_last();
if(last_error==NULL) if(last_error==nullptr)
return std::string(); return std::string();
else else
return last_error->message; return last_error->message;
@ -49,9 +49,9 @@ Git::Repository::Diff::Lines Git::Repository::Diff::get_lines(const std::string
Error error; Error error;
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
#if LIBGIT2_SOVERSION>=23 #if LIBGIT2_SOVERSION>=23
error.code=git_diff_blob_to_buffer(blob.get(), NULL, buffer.c_str(), buffer.size(), NULL, &options, NULL, NULL, hunk_cb, NULL, &lines); error.code=git_diff_blob_to_buffer(blob.get(), nullptr, buffer.c_str(), buffer.size(), nullptr, &options, nullptr, nullptr, hunk_cb, nullptr, &lines);
#else #else
error.code=git_diff_blob_to_buffer(blob.get(), NULL, buffer.c_str(), buffer.size(), NULL, &options, NULL, hunk_cb, NULL, &lines); error.code=git_diff_blob_to_buffer(blob.get(), nullptr, buffer.c_str(), buffer.size(), nullptr, &options, nullptr, hunk_cb, nullptr, &lines);
#endif #endif
if(error) if(error)
throw std::runtime_error(error.message()); throw std::runtime_error(error.message());
@ -77,9 +77,9 @@ std::string Git::Repository::Diff::get_details(const std::string &buffer, int li
Error error; Error error;
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
#if LIBGIT2_SOVERSION>=23 #if LIBGIT2_SOVERSION>=23
error.code=git_diff_blob_to_buffer(blob.get(), NULL, buffer.c_str(), buffer.size(), NULL, &options, NULL, NULL, NULL, line_cb, &details); error.code=git_diff_blob_to_buffer(blob.get(), nullptr, buffer.c_str(), buffer.size(), nullptr, &options, nullptr, nullptr, nullptr, line_cb, &details);
#else #else
error.code=git_diff_blob_to_buffer(blob.get(), NULL, buffer.c_str(), buffer.size(), NULL, &options, NULL, NULL, line_cb, &details); error.code=git_diff_blob_to_buffer(blob.get(), nullptr, buffer.c_str(), buffer.size(), nullptr, &options, nullptr, nullptr, line_cb, &details);
#endif #endif
if(error) if(error)
throw std::runtime_error(error.message()); throw std::runtime_error(error.message());
@ -92,7 +92,7 @@ Git::Repository::Repository(const boost::filesystem::path &path) {
Error error; Error error;
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
auto path_str=path.generic_string(); auto path_str=path.generic_string();
error.code = git_repository_open_ext(&repository_ptr, path_str.c_str(), 0, NULL); error.code = git_repository_open_ext(&repository_ptr, path_str.c_str(), 0, nullptr);
if(error) if(error)
throw std::runtime_error(error.message()); throw std::runtime_error(error.message());
} }
@ -235,7 +235,7 @@ boost::filesystem::path Git::Repository::get_root_path(const boost::filesystem::
Error error; Error error;
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
auto path_str=path.generic_string(); auto path_str=path.generic_string();
error.code = git_repository_discover(&root, path_str.c_str(), 0, NULL); error.code = git_repository_discover(&root, path_str.c_str(), 0, nullptr);
if(error) if(error)
throw std::runtime_error(error.message()); throw std::runtime_error(error.message());
} }

4
src/notebook.cc

@ -159,8 +159,8 @@ void Notebook::open(const boost::filesystem::path &file_path, size_t notebook_in
source_views.emplace_back(new Source::GenericView(file_path, language)); source_views.emplace_back(new Source::GenericView(file_path, language));
source_views.back()->scroll_to_cursor_delayed=[this](Source::View* view, bool center, bool show_tooltips) { source_views.back()->scroll_to_cursor_delayed=[this](Source::View* view, bool center, bool show_tooltips) {
while(g_main_context_pending(NULL)) while(g_main_context_pending(nullptr))
g_main_context_iteration(NULL, false); g_main_context_iteration(nullptr, false);
if(get_current_view()==view) { if(get_current_view()==view) {
if(center) if(center)
view->scroll_to(view->get_buffer()->get_insert(), 0.0, 1.0, 0.5); view->scroll_to(view->get_buffer()->get_insert(), 0.0, 1.0, 0.5);

8
src/project.cc

@ -592,8 +592,8 @@ void Project::Markdown::compile_and_run() {
#ifdef __linux #ifdef __linux
uri="file://"+uri; uri="file://"+uri;
#endif #endif
GError* error=NULL; GError* error=nullptr;
gtk_show_uri(NULL, uri.c_str(), GDK_CURRENT_TIME, &error); gtk_show_uri(nullptr, uri.c_str(), GDK_CURRENT_TIME, &error);
g_clear_error(&error); g_clear_error(&error);
#endif #endif
} }
@ -625,8 +625,8 @@ void Project::HTML::compile_and_run() {
#ifdef __linux #ifdef __linux
uri="file://"+uri; uri="file://"+uri;
#endif #endif
GError* error=NULL; GError* error=nullptr;
gtk_show_uri(NULL, uri.c_str(), GDK_CURRENT_TIME, &error); gtk_show_uri(nullptr, uri.c_str(), GDK_CURRENT_TIME, &error);
g_clear_error(&error); g_clear_error(&error);
#endif #endif
} }

4
src/selectiondialog.cc

@ -122,8 +122,8 @@ void SelectionDialogBase::show() {
cursor_changed(); cursor_changed();
} }
else if(list_view_text.get_model()->children().begin()!=list_view_text.get_selection()->get_selected()) { else if(list_view_text.get_model()->children().begin()!=list_view_text.get_selection()->get_selected()) {
while(g_main_context_pending(NULL)) while(g_main_context_pending(nullptr))
g_main_context_iteration(NULL, false); g_main_context_iteration(nullptr, false);
list_view_text.scroll_to_row(list_view_text.get_model()->get_path(list_view_text.get_selection()->get_selected()), 0.5); list_view_text.scroll_to_row(list_view_text.get_model()->get_path(list_view_text.get_selection()->get_selected()), 0.5);
} }
} }

12
src/source.cc

@ -30,7 +30,7 @@ namespace sigc {
Glib::RefPtr<Gsv::Language> Source::guess_language(const boost::filesystem::path &file_path) { Glib::RefPtr<Gsv::Language> Source::guess_language(const boost::filesystem::path &file_path) {
auto language_manager=Gsv::LanguageManager::get_default(); auto language_manager=Gsv::LanguageManager::get_default();
bool result_uncertain = false; bool result_uncertain = false;
auto content_type = Gio::content_type_guess(file_path.string(), NULL, 0, result_uncertain); auto content_type = Gio::content_type_guess(file_path.string(), nullptr, 0, result_uncertain);
if(result_uncertain) { if(result_uncertain) {
content_type.clear(); content_type.clear();
} }
@ -380,7 +380,7 @@ void Source::View::configure() {
diagnostic_tag_underline->property_underline()=Pango::Underline::UNDERLINE_ERROR; diagnostic_tag_underline->property_underline()=Pango::Underline::UNDERLINE_ERROR;
auto tag_class=G_OBJECT_GET_CLASS(diagnostic_tag_underline->gobj()); //For older GTK+ 3 versions: auto tag_class=G_OBJECT_GET_CLASS(diagnostic_tag_underline->gobj()); //For older GTK+ 3 versions:
auto param_spec=g_object_class_find_property(tag_class, "underline-rgba"); auto param_spec=g_object_class_find_property(tag_class, "underline-rgba");
if(param_spec!=NULL) { if(param_spec!=nullptr) {
diagnostic_tag_underline->set_property("underline-rgba", Gdk::RGBA(warning_property)); diagnostic_tag_underline->set_property("underline-rgba", Gdk::RGBA(warning_property));
} }
} }
@ -509,7 +509,7 @@ void Source::View::search_highlight(const std::string &text, bool case_sensitive
gtk_source_search_settings_set_case_sensitive(search_settings, case_sensitive); gtk_source_search_settings_set_case_sensitive(search_settings, case_sensitive);
gtk_source_search_settings_set_regex_enabled(search_settings, regex); gtk_source_search_settings_set_regex_enabled(search_settings, regex);
gtk_source_search_settings_set_search_text(search_settings, text.c_str()); gtk_source_search_settings_set_search_text(search_settings, text.c_str());
search_occurrences_updated(NULL, NULL, this); search_occurrences_updated(nullptr, nullptr, this);
} }
void Source::View::search_forward() { void Source::View::search_forward() {
@ -541,7 +541,7 @@ void Source::View::replace_forward(const std::string &replacement) {
Gtk::TextIter match_start, match_end; Gtk::TextIter match_start, match_end;
if(gtk_source_search_context_forward(search_context, start.gobj(), match_start.gobj(), match_end.gobj())) { if(gtk_source_search_context_forward(search_context, start.gobj(), match_start.gobj(), match_end.gobj())) {
auto offset=match_start.get_offset(); auto offset=match_start.get_offset();
gtk_source_search_context_replace(search_context, match_start.gobj(), match_end.gobj(), replacement.c_str(), replacement.size(), NULL); gtk_source_search_context_replace(search_context, match_start.gobj(), match_end.gobj(), replacement.c_str(), replacement.size(), nullptr);
Glib::ustring replacement_ustring=replacement; Glib::ustring replacement_ustring=replacement;
get_buffer()->select_range(get_buffer()->get_iter_at_offset(offset), get_buffer()->get_iter_at_offset(offset+replacement_ustring.size())); get_buffer()->select_range(get_buffer()->get_iter_at_offset(offset), get_buffer()->get_iter_at_offset(offset+replacement_ustring.size()));
@ -556,7 +556,7 @@ void Source::View::replace_backward(const std::string &replacement) {
Gtk::TextIter match_start, match_end; Gtk::TextIter match_start, match_end;
if(gtk_source_search_context_backward(search_context, start.gobj(), match_start.gobj(), match_end.gobj())) { if(gtk_source_search_context_backward(search_context, start.gobj(), match_start.gobj(), match_end.gobj())) {
auto offset=match_start.get_offset(); auto offset=match_start.get_offset();
gtk_source_search_context_replace(search_context, match_start.gobj(), match_end.gobj(), replacement.c_str(), replacement.size(), NULL); gtk_source_search_context_replace(search_context, match_start.gobj(), match_end.gobj(), replacement.c_str(), replacement.size(), nullptr);
get_buffer()->select_range(get_buffer()->get_iter_at_offset(offset), get_buffer()->get_iter_at_offset(offset+replacement.size())); get_buffer()->select_range(get_buffer()->get_iter_at_offset(offset), get_buffer()->get_iter_at_offset(offset+replacement.size()));
scroll_to(get_buffer()->get_insert()); scroll_to(get_buffer()->get_insert());
@ -564,7 +564,7 @@ void Source::View::replace_backward(const std::string &replacement) {
} }
void Source::View::replace_all(const std::string &replacement) { void Source::View::replace_all(const std::string &replacement) {
gtk_source_search_context_replace_all(search_context, replacement.c_str(), replacement.size(), NULL); gtk_source_search_context_replace_all(search_context, replacement.c_str(), replacement.size(), nullptr);
} }
void Source::View::paste() { void Source::View::paste() {

6
src/source_clang.cc

@ -756,7 +756,7 @@ void Source::ClangViewAutocomplete::autocomplete() {
std::vector<Source::ClangViewAutocomplete::AutoCompleteData> Source::ClangViewAutocomplete::autocomplete_get_suggestions(const std::string &buffer, int line_number, int column) { std::vector<Source::ClangViewAutocomplete::AutoCompleteData> Source::ClangViewAutocomplete::autocomplete_get_suggestions(const std::string &buffer, int line_number, int column) {
std::vector<AutoCompleteData> suggestions; std::vector<AutoCompleteData> suggestions;
auto results=clang_tu->get_code_completions(buffer, line_number, column); auto results=clang_tu->get_code_completions(buffer, line_number, column);
if(results.cx_results==NULL) { if(results.cx_results==nullptr) {
auto expected=ParseState::PROCESSING; auto expected=ParseState::PROCESSING;
parse_state.compare_exchange_strong(expected, ParseState::RESTARTING); parse_state.compare_exchange_strong(expected, ParseState::RESTARTING);
return suggestions; return suggestions;
@ -1321,8 +1321,8 @@ void Source::ClangViewRefactor::wait_parsing(const std::vector<Source::View*> &v
} }
if(message) { if(message) {
for(;;) { for(;;) {
while(g_main_context_pending(NULL)) while(g_main_context_pending(nullptr))
g_main_context_iteration(NULL, false); g_main_context_iteration(nullptr, false);
bool all_parsed=true; bool all_parsed=true;
for(auto &clang_view: clang_views) { for(auto &clang_view: clang_views) {
if(!clang_view->parsed) { if(!clang_view->parsed) {

20
src/source_spellcheck.cc

@ -16,12 +16,12 @@ namespace sigc {
#endif #endif
} }
AspellConfig* Source::SpellCheckView::spellcheck_config=NULL; AspellConfig* Source::SpellCheckView::spellcheck_config=nullptr;
Source::SpellCheckView::SpellCheckView() : Gsv::View() { Source::SpellCheckView::SpellCheckView() : Gsv::View() {
if(spellcheck_config==NULL) if(spellcheck_config==nullptr)
spellcheck_config=new_aspell_config(); spellcheck_config=new_aspell_config();
spellcheck_checker=NULL; spellcheck_checker=nullptr;
auto tag=get_buffer()->create_tag("spellcheck_error"); auto tag=get_buffer()->create_tag("spellcheck_error");
tag->property_underline()=Pango::Underline::UNDERLINE_ERROR; tag->property_underline()=Pango::Underline::UNDERLINE_ERROR;
@ -41,7 +41,7 @@ Source::SpellCheckView::SpellCheckView() : Gsv::View() {
}); });
get_buffer()->signal_changed().connect([this](){ get_buffer()->signal_changed().connect([this](){
if(spellcheck_checker==NULL) if(spellcheck_checker==nullptr)
return; return;
delayed_spellcheck_suggestions_connection.disconnect(); delayed_spellcheck_suggestions_connection.disconnect();
@ -131,7 +131,7 @@ Source::SpellCheckView::SpellCheckView() : Gsv::View() {
}); });
get_buffer()->signal_mark_set().connect([this](const Gtk::TextBuffer::iterator& iter, const Glib::RefPtr<Gtk::TextBuffer::Mark>& mark) { get_buffer()->signal_mark_set().connect([this](const Gtk::TextBuffer::iterator& iter, const Glib::RefPtr<Gtk::TextBuffer::Mark>& mark) {
if(spellcheck_checker==NULL) if(spellcheck_checker==nullptr)
return; return;
if(mark->get_name()=="insert") { if(mark->get_name()=="insert") {
@ -191,7 +191,7 @@ Source::SpellCheckView::~SpellCheckView() {
delayed_spellcheck_suggestions_connection.disconnect(); delayed_spellcheck_suggestions_connection.disconnect();
delayed_spellcheck_error_clear.disconnect(); delayed_spellcheck_error_clear.disconnect();
if(spellcheck_checker!=NULL) if(spellcheck_checker!=nullptr)
delete_aspell_speller(spellcheck_checker);//asd delete_aspell_speller(spellcheck_checker);//asd
} }
@ -201,9 +201,9 @@ void Source::SpellCheckView::configure() {
aspell_config_replace(spellcheck_config, "encoding", "utf-8"); aspell_config_replace(spellcheck_config, "encoding", "utf-8");
} }
spellcheck_possible_err=new_aspell_speller(spellcheck_config); spellcheck_possible_err=new_aspell_speller(spellcheck_config);
if(spellcheck_checker!=NULL) if(spellcheck_checker!=nullptr)
delete_aspell_speller(spellcheck_checker); delete_aspell_speller(spellcheck_checker);
spellcheck_checker=NULL; spellcheck_checker=nullptr;
if (aspell_error_number(spellcheck_possible_err) != 0) if (aspell_error_number(spellcheck_possible_err) != 0)
std::cerr << "Spell check error: " << aspell_error_message(spellcheck_possible_err) << std::endl; std::cerr << "Spell check error: " << aspell_error_message(spellcheck_possible_err) << std::endl;
else else
@ -218,7 +218,7 @@ void Source::SpellCheckView::hide_dialogs() {
} }
void Source::SpellCheckView::spellcheck(const Gtk::TextIter& start, const Gtk::TextIter& end) { void Source::SpellCheckView::spellcheck(const Gtk::TextIter& start, const Gtk::TextIter& end) {
if(spellcheck_checker==NULL) if(spellcheck_checker==nullptr)
return; return;
auto iter=start; auto iter=start;
while(iter && iter<end) { while(iter && iter<end) {
@ -353,7 +353,7 @@ std::vector<std::string> Source::SpellCheckView::spellcheck_get_suggestions(cons
std::vector<std::string> words; std::vector<std::string> words;
const char *word; const char *word;
while ((word = aspell_string_enumeration_next(elements))!= NULL) { while ((word = aspell_string_enumeration_next(elements))!= nullptr) {
words.emplace_back(word); words.emplace_back(word);
} }
delete_aspell_string_enumeration(elements); delete_aspell_string_enumeration(elements);

4
src/terminal.cc

@ -334,8 +334,8 @@ void Terminal::clear() {
for(auto &in_progress: in_progresses) for(auto &in_progress: in_progresses)
in_progress->stop=true; in_progress->stop=true;
} }
while(g_main_context_pending(NULL)) while(g_main_context_pending(nullptr))
g_main_context_iteration(NULL, false); g_main_context_iteration(nullptr, false);
get_buffer()->set_text(""); get_buffer()->set_text("");
} }

4
src/window.cc

@ -513,8 +513,8 @@ void Window::set_menu_actions() {
#ifdef __APPLE__ #ifdef __APPLE__
Terminal::get().process("open \""+uri+"\""); Terminal::get().process("open \""+uri+"\"");
#else #else
GError* error=NULL; GError* error=nullptr;
gtk_show_uri(NULL, uri.c_str(), GDK_CURRENT_TIME, &error); gtk_show_uri(nullptr, uri.c_str(), GDK_CURRENT_TIME, &error);
g_clear_error(&error); g_clear_error(&error);
#endif #endif
} }

Loading…
Cancel
Save