Skip to content

Commit

Permalink
Feature #2504 nullptr (#2505)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnHalleyGotway authored Apr 6, 2023
1 parent a33aa0a commit 39c20a2
Show file tree
Hide file tree
Showing 77 changed files with 316 additions and 316 deletions.
14 changes: 7 additions & 7 deletions src/basic/enum_to_string/code.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ char upper[256];
char pound_define[256];
char junk[256];
int len, scope_len, max_len;
char * len_name = (char *) NULL;
char * len_name = (char *) nullptr;


max_len = 0;
Expand Down Expand Up @@ -240,7 +240,7 @@ f << "\n\n"

f.close();

if ( len_name ) { delete [] len_name; len_name = (char *) NULL; }
if ( len_name ) { delete [] len_name; len_name = (char *) nullptr; }

return;

Expand All @@ -263,7 +263,7 @@ char upper[256];
char pound_define[256];
char junk[256];
int len, scope_len, max_len;
char * len_name = (char *) NULL;
char * len_name = (char *) nullptr;

max_len = 0;

Expand Down Expand Up @@ -407,7 +407,7 @@ f << "\n\n"

f.close();

if ( len_name ) { delete [] len_name; len_name = (char *) NULL; }
if ( len_name ) { delete [] len_name; len_name = (char *) nullptr; }

return;

Expand Down Expand Up @@ -962,7 +962,7 @@ void warning(ofstream & f)

int j;

const char * short_name = (const char *) NULL;
const char * short_name = (const char *) nullptr;

//
// strip the leading path from header_filename
Expand Down Expand Up @@ -1001,7 +1001,7 @@ void patch_name(char * len_name)

int j, n;
int pos;
char * new_name = (char *) NULL;
char * new_name = (char *) nullptr;
char c;
const char *method_name = "patch_name() -> ";

Expand Down Expand Up @@ -1042,7 +1042,7 @@ m_strcpy(len_name, new_name, method_name);
// done
//

if ( new_name ) { delete [] new_name; new_name = (char *) NULL; }
if ( new_name ) { delete [] new_name; new_name = (char *) nullptr; }

return;

Expand Down
2 changes: 1 addition & 1 deletion src/basic/enum_to_string/enum_to_string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ header_filename = argv[1];

yydebug = debug;

if ( (yyin = met_fopen(header_filename, "r")) == NULL ) {
if ( (yyin = met_fopen(header_filename, "r")) == nullptr ) {

cerr << "\n\n unable to open input file \"" << header_filename << "\"\n\n";

Expand Down
40 changes: 20 additions & 20 deletions src/basic/enum_to_string/info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,17 @@ void EnumInfo::init_from_scratch()

{

s = (char **) NULL;
s = (char **) nullptr;

Name = (char *) NULL;
Name = (char *) nullptr;

LowerCaseName = (char *) NULL;
LowerCaseName = (char *) nullptr;

Scope = (char *) NULL;
Scope = (char *) nullptr;

U_Scope = (char *) NULL;
U_Scope = (char *) nullptr;

Header = (char *) NULL;
Header = (char *) nullptr;

Nalloc = Nids = 0;

Expand All @@ -127,21 +127,21 @@ int j;

for (j=0; j<Nids; ++j) {

if ( s[j] ) { delete [] s[j]; s[j] = (char *) NULL; }
if ( s[j] ) { delete [] s[j]; s[j] = (char *) nullptr; }

}

delete [] s; s = (char **) NULL;
delete [] s; s = (char **) nullptr;

if ( Name ) { delete [] Name; Name = (char *) NULL; }
if ( Name ) { delete [] Name; Name = (char *) nullptr; }

if ( LowerCaseName ) { delete [] LowerCaseName; LowerCaseName = (char *) NULL; }
if ( LowerCaseName ) { delete [] LowerCaseName; LowerCaseName = (char *) nullptr; }

if ( Scope ) { delete [] Scope; Scope = (char *) NULL; }
if ( Scope ) { delete [] Scope; Scope = (char *) nullptr; }

if ( U_Scope ) { delete [] U_Scope; U_Scope = (char *) NULL; }
if ( U_Scope ) { delete [] U_Scope; U_Scope = (char *) nullptr; }

if ( Header ) { delete [] Header; Header = (char *) NULL; }
if ( Header ) { delete [] Header; Header = (char *) nullptr; }

Nalloc = Nids = 0;

Expand Down Expand Up @@ -199,7 +199,7 @@ n = (n + enuminfo_alloc_increment - 1)/enuminfo_alloc_increment;
n *= enuminfo_alloc_increment;

int j;
char ** u = (char **) NULL;
char ** u = (char **) nullptr;

u = s;

Expand All @@ -213,7 +213,7 @@ if ( !s ) {

}

for (j=0; j<n; ++j) s[j] = (char *) NULL;
for (j=0; j<n; ++j) s[j] = (char *) nullptr;

if ( u ) {

Expand Down Expand Up @@ -315,9 +315,9 @@ void EnumInfo::set_name(const char * text)
{
const char *method_name = "EnumInfo::set_name() -> ";

if ( Name ) { delete [] Name; Name = (char *) NULL; }
if ( Name ) { delete [] Name; Name = (char *) nullptr; }

if ( LowerCaseName ) { delete [] LowerCaseName; LowerCaseName = (char *) NULL; }
if ( LowerCaseName ) { delete [] LowerCaseName; LowerCaseName = (char *) nullptr; }

if ( !text ) return;

Expand Down Expand Up @@ -355,9 +355,9 @@ void EnumInfo::set_scope(const char * text)
{
const char *method_name = "EnumInfo::set_scope() -> ";

if ( Scope ) { delete [] Scope; Scope = (char *) NULL; }
if ( Scope ) { delete [] Scope; Scope = (char *) nullptr; }

if ( U_Scope ) { delete [] U_Scope; U_Scope = (char *) NULL; }
if ( U_Scope ) { delete [] U_Scope; U_Scope = (char *) nullptr; }

if ( !text ) return;

Expand Down Expand Up @@ -404,7 +404,7 @@ void EnumInfo::set_header(const char * text)
{
const char *method_name = "EnumInfo::set_header() -> ";

if ( Header ) { delete [] Header; Header = (char *) NULL; }
if ( Header ) { delete [] Header; Header = (char *) nullptr; }

int k;

Expand Down
10 changes: 5 additions & 5 deletions src/basic/vx_cal/time_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void TimeArray::init_from_scratch()

{

e = (unixtime*) NULL;
e = (unixtime*) nullptr;

clear();

Expand All @@ -138,7 +138,7 @@ void TimeArray::clear()

{

if ( e ) { delete [] e; e = (unixtime *) NULL; }
if ( e ) { delete [] e; e = (unixtime *) nullptr; }

Nelements = Nalloc = 0;

Expand Down Expand Up @@ -218,7 +218,7 @@ if ( ! exact ) {

}

unixtime * u = (unixtime *) NULL;
unixtime * u = (unixtime *) nullptr;

u = new unixtime [n];

Expand All @@ -243,11 +243,11 @@ if ( e ) {

}

delete [] e; e = (unixtime *) NULL;
delete [] e; e = (unixtime *) nullptr;

}

e = u; u = (unixtime *) NULL;
e = u; u = (unixtime *) nullptr;

Nalloc = n;

Expand Down
16 changes: 8 additions & 8 deletions src/basic/vx_config/config.tab.cc
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,15 @@ static void do_user_function_def();


#line 265 "config.tab.cc" /* yacc.c:337 */
# ifndef YY_NULLPTR
# ifndef YY_nullptrPTR
# if defined __cplusplus
# if 201103L <= __cplusplus
# define YY_NULLPTR nullptr
# define YY_nullptrPTR nullptr
# else
# define YY_NULLPTR 0
# define YY_nullptrPTR 0
# endif
# else
# define YY_NULLPTR ((void*)0)
# define YY_nullptrPTR ((void*)0)
# endif
# endif

Expand Down Expand Up @@ -694,7 +694,7 @@ static const char *const yytname[] =
"dictionary_list", "string_list", "threshold_list", "threshold",
"thresh_node", "simple_thresh", "number", "boolean_list", "opt_semi",
"opt_comma", "expression", "$@2", "$@3", "expression_list",
"piecewise_linear", "point_list", "point", YY_NULLPTR
"piecewise_linear", "point_list", "point", YY_nullptrPTR
};
#endif

Expand Down Expand Up @@ -1173,11 +1173,11 @@ static int
yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
yytype_int16 *yyssp, int yytoken)
{
YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
YYSIZE_T yysize0 = yytnamerr (YY_nullptrPTR, yytname[yytoken]);
YYSIZE_T yysize = yysize0;
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
/* Internationalized format string. */
const char *yyformat = YY_NULLPTR;
const char *yyformat = YY_nullptrPTR;
/* Arguments of yyformat. */
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
/* Number of reported tokens (one for the "unexpected", one per
Expand Down Expand Up @@ -1234,7 +1234,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
}
yyarg[yycount++] = yytname[yyx];
{
YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
YYSIZE_T yysize1 = yysize + yytnamerr (YY_nullptrPTR, yytname[yyx]);
if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
yysize = yysize1;
else
Expand Down
2 changes: 1 addition & 1 deletion src/basic/vx_config/config_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ Filename.add(bison_input_filename);

configdebug = (Debug ? 1 : 0);

if ( (configin = met_fopen(bison_input_filename, "r")) == NULL ) {
if ( (configin = met_fopen(bison_input_filename, "r")) == nullptr ) {

mlog << Error << "\nMetConfig::read(const char *) -> "
<< "unable to open input file \"" << bison_input_filename << "\"\n\n";
Expand Down
4 changes: 2 additions & 2 deletions src/basic/vx_config/config_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2031,7 +2031,7 @@ int parse_conf_percentile(Dictionary *dict) {
///////////////////////////////////////////////////////////////////////////////

ConcatString parse_conf_tmp_dir(Dictionary *dict) {
DIR* odir = NULL;
DIR* odir = nullptr;
ConcatString tmp_dir_path;

if(!get_env("MET_TMP_DIR", tmp_dir_path)) {
Expand All @@ -2045,7 +2045,7 @@ ConcatString parse_conf_tmp_dir(Dictionary *dict) {
}

// Make sure that it exists
if((odir = met_opendir(tmp_dir_path.c_str())) == NULL) {
if((odir = met_opendir(tmp_dir_path.c_str())) == nullptr) {
mlog << Error << "\nparse_conf_tmp_dir() -> "
<< "Cannot access the \"" << conf_key_tmp_dir << "\" directory: "
<< tmp_dir_path << "\n\n";
Expand Down
8 changes: 4 additions & 4 deletions src/basic/vx_log/concat_string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ int ConcatString::format(const char *fmt, ...)
{
va_list vl;
int status = -1;
char *tmp = NULL;
char *tmp = nullptr;

va_start(vl, fmt);
status = vasprintf(&tmp, fmt, vl);
Expand Down Expand Up @@ -1180,7 +1180,7 @@ bool is_empty(const char * text)

{

return ( (text == NULL) || (*text == 0) || (m_strlen(text) == 0));
return ( (text == nullptr) || (*text == 0) || (m_strlen(text) == 0));

}

Expand All @@ -1201,7 +1201,7 @@ env_value.clear();

// SonarQube: two ifs to avoid the side effect by the logical || operator
if (str.find('/') != string::npos) return(false);
if ((ptr = getenv(env_name)) == NULL) return(false);
if ((ptr = getenv(env_name)) == nullptr) return(false);

env_value = ptr;
str = env_value;
Expand Down Expand Up @@ -1241,7 +1241,7 @@ while ((pos = str.find('$', pos)) != string::npos) {
}
}
nested_name = str.substr(pos_env, (pos_env_end-pos_env));
if((ptr = getenv(nested_name.c_str())) == NULL) {
if((ptr = getenv(nested_name.c_str())) == nullptr) {
mlog << Error << "\n" << method_name
<< "can't get value of nested environment variable \""
<< nested_name << "\" from " << env_name << "\n\n";
Expand Down
8 changes: 4 additions & 4 deletions src/basic/vx_log/str_wrappers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ char *m_strcpy2(const char *from_str, const char *method_name, const char *extra
}
else {
mlog << Error << "\n" << method_name
<< " Do not copy the string because a from_string is NULL. "
<< " Do not copy the string because a from_string is nullptr. "
<< (extra_msg == 0 ? "" : extra_msg) << "\n\n";
}

Expand All @@ -79,12 +79,12 @@ void m_strncpy(char *to_str, const char *from_str, const int buf_len,
const char *method_name, const char *extra_msg, bool truncate) {
if (!from_str){
mlog << Warning << "\n" << method_name
<< " Do not copy the string because a from_string is NULL. "
<< " Do not copy the string because a from_string is nullptr. "
<< (extra_msg == 0 ? "" : extra_msg) << "\n\n";
}
else if (!to_str){
mlog << Warning << "\n" << method_name
<< " Do not copy the string because a to_string is NULL. "
<< " Do not copy the string because a to_string is nullptr. "
<< (extra_msg == 0 ? "" : extra_msg) << "\n\n";
}
else { // (from_str && to_str)
Expand Down Expand Up @@ -131,7 +131,7 @@ bool m_replace_char(char *str_buf, char from_ch, char to_ch, bool all_instances)
////////////////////////////////////////////////////////////////////////

void m_rstrip(char *str_buf, int buf_len, bool find_white_ch) {
// Make sure it's NULL terminated
// Make sure it's nullptr terminated
if (buf_len >= 0) str_buf[buf_len] = '\0';
// Change the trailing blank space to a null
int str_len = m_strlen(str_buf);
Expand Down
Loading

0 comments on commit 39c20a2

Please sign in to comment.