From: Richard Kreckel Date: Mon, 22 Feb 2016 21:51:40 +0000 (+0100) Subject: Use C++11 'nullptr' where applicable. X-Git-Tag: release_1-7-0~7^2~5 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=cd22e73d44e3320898f62a0accdbbe005b33d3e5 Use C++11 'nullptr' where applicable. --- diff --git a/ginac/archive.cpp b/ginac/archive.cpp index a8bc5575..27ebfb89 100644 --- a/ginac/archive.cpp +++ b/ginac/archive.cpp @@ -550,7 +550,7 @@ ex archive_node::unarchive(lst &sym_lst) const } int unarchive_table_t::usecount = 0; -unarchive_map_t* unarchive_table_t::unarch_map = 0; +unarchive_map_t* unarchive_table_t::unarch_map = nullptr; unarchive_table_t::unarchive_table_t() { diff --git a/ginac/function.cppy b/ginac/function.cppy index d9a59dc7..d020d65f 100644 --- a/ginac/function.cppy +++ b/ginac/function.cppy @@ -79,7 +79,7 @@ void function_options::initialize() nparams = 0; eval_f = evalf_f = real_part_f = imag_part_f = conjugate_f = expand_f = derivative_f = expl_derivative_f = power_f = series_f = nullptr; - info_f = 0; + info_f = nullptr; evalf_params_first = true; use_return_type = false; eval_use_exvector_args = false; @@ -430,7 +430,7 @@ ex function::evalf() const } } - if (opt.evalf_f==0) { + if (opt.evalf_f==nullptr) { return function(serial,eseq).hold(); } current_serial = serial; @@ -489,7 +489,7 @@ ex function::series(const relational & r, int order, unsigned options) const GINAC_ASSERT(serial *current_vector; }; -std::vector* lanczos_coeffs::coeffs = 0; +std::vector* lanczos_coeffs::coeffs = nullptr; bool lanczos_coeffs::sufficiently_accurate(int digits) { if (digits<=20) { diff --git a/ginac/operators.cpp b/ginac/operators.cpp index 9f81e2e5..eb8566c3 100644 --- a/ginac/operators.cpp +++ b/ginac/operators.cpp @@ -289,8 +289,8 @@ static void my_ios_callback(std::ios_base::event ev, std::ios_base & s, int i) print_context *p = static_cast(s.pword(i)); if (ev == std::ios_base::erase_event) { delete p; - s.pword(i) = 0; - } else if (ev == std::ios_base::copyfmt_event && p != 0) + s.pword(i) = nullptr; + } else if (ev == std::ios_base::copyfmt_event && p != nullptr) s.pword(i) = p->duplicate(); } diff --git a/ginac/relational.cpp b/ginac/relational.cpp index 8b18897e..72d19f5d 100644 --- a/ginac/relational.cpp +++ b/ginac/relational.cpp @@ -298,7 +298,7 @@ unsigned relational::calchash() const relational::safe_bool relational::make_safe_bool(bool cond) const { - return cond? &safe_bool_helper::nonnull : 0; + return cond? &safe_bool_helper::nonnull : nullptr; } /** Cast the relational into a Boolean, mainly for evaluation within an diff --git a/ginsh/ginsh_lexer.lpp b/ginsh/ginsh_lexer.lpp index eba25be7..000b1333 100644 --- a/ginsh/ginsh_lexer.lpp +++ b/ginsh/ginsh_lexer.lpp @@ -144,7 +144,7 @@ real_symbols return T_REAL_SYMBOLS; */ static int line_length = 0; -static char *line_read = NULL; +static char *line_read = nullptr; static char *line_ptr; // Input function that uses libreadline for interactive input @@ -208,7 +208,7 @@ static int ginsh_input(char *buf, int max_size) // List of input files to be processed int num_files = 0; -char **file_list = NULL; +char **file_list = nullptr; // EOF encountered, connect to next file. If this was the last file, // connect to stdin. If this was stdin, terminate the scanner. @@ -220,7 +220,7 @@ int yywrap() fclose(yyin); if (num_files) { yyin = fopen(*file_list, "r"); - if (yyin == NULL) { + if (yyin == nullptr) { cerr << "Can't open " << *file_list << endl; return 1; } diff --git a/ginsh/ginsh_parser.ypp b/ginsh/ginsh_parser.ypp index 2bdfc491..4813f63a 100644 --- a/ginsh/ginsh_parser.ypp +++ b/ginsh/ginsh_parser.ypp @@ -90,7 +90,7 @@ typedef ex (*fcnp)(const exprseq &e); typedef ex (*fcnp2)(const exprseq &e, int serial); struct fcn_desc { - fcn_desc() : p(NULL), num_params(0), is_ginac(false), serial(0) {} + fcn_desc() : p(nullptr), num_params(0), is_ginac(false), serial(0) {} fcn_desc(fcnp func, int num) : p(func), num_params(num), is_ginac(false), serial(0) {} fcn_desc(fcnp2 func, int num, int ser) : p((fcnp)func), num_params(num), is_ginac(true), serial(ser) {} @@ -647,7 +647,7 @@ static const fcn_init builtin_fcns[] = { {"transpose", f_transpose, 1}, {"unassign", f_unassign, 1}, {"unit", f_unit, 2}, - {NULL, f_dummy, 0} // End marker + {nullptr, f_dummy, 0} // End marker }; struct fcn_help_init { @@ -685,7 +685,7 @@ static const fcn_help_init builtin_help[] = { {"H", "harmonic polylogarithm"}, {"Order", "order term function (for truncated power series)"}, {"Derivative", "inert differential operator"}, - {NULL, NULL} // End marker + {nullptr, nullptr} // End marker }; #include "ginsh_extensions.h" @@ -840,7 +840,7 @@ static char *fcn_generator(const char *text, int state) if (strncmp(fcn_name, text, len) == 0) return strdup(fcn_name); } - return NULL; + return nullptr; } #ifdef HAVE_LIBREADLINE @@ -923,7 +923,7 @@ int main(int argc, char **argv) file_list = argv + 1; if (num_files) { yyin = fopen(*file_list, "r"); - if (yyin == NULL) { + if (yyin == nullptr) { cerr << "Can't open " << *file_list << endl; exit(1); }