diff --git a/src/basic/enum_to_string/enum_to_string.cc b/src/basic/enum_to_string/enum_to_string.cc index bd0e03dc19..30284b209a 100644 --- a/src/basic/enum_to_string/enum_to_string.cc +++ b/src/basic/enum_to_string/enum_to_string.cc @@ -16,8 +16,6 @@ static const int debug = 0; //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include @@ -35,6 +33,9 @@ using namespace std; #include "enum_to_string.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -157,7 +158,7 @@ if ( parse_status != 0 ) { } -return ( 0 ); +return 0; } @@ -171,13 +172,13 @@ void parse_command_line(int &argc, char **argv) if ( argc == 1 ) { usage(); exit ( 1 ); } -int j, found; +int found; do { found = 0; - for (j=1; j #include #include @@ -22,6 +19,10 @@ using namespace std; #include "str_wrappers.h" + +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -155,7 +156,7 @@ while ( 1 ) { // // cout << "\n\n" << flush; -return ( t ); +return t; } @@ -266,7 +267,7 @@ if ( is_id() ) { if ( do_id() ) return ( token(ID) ); } -return ( skip ); +return skip; } @@ -330,7 +331,7 @@ if ( k == char_class_digit ) return ( true ); if ( k == char_class_alpha ) return ( true ); -return ( false ); +return false; } @@ -378,9 +379,9 @@ bool is_id() if ( char_class[lexeme[0]] != char_class_alpha ) return ( false ); -int j, k; +int k; -for (j=0; j #include #include @@ -23,6 +20,8 @@ using namespace std; #include "str_wrappers.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// @@ -83,7 +82,7 @@ if ( this == &e ) return ( *this ); assign(e); -return ( *this ); +return *this; } @@ -239,7 +238,7 @@ if ( this == &ss ) return ( *this ); assign(ss); -return ( *this ); +return *this; } @@ -313,7 +312,7 @@ if ( (pos < 0) || (pos >= N) ) { } -return ( s[pos] ); +return s[pos]; } @@ -437,7 +436,7 @@ s << " level = " << (sse.level()) << "\n"; s.flush(); -return ( s ); +return s; } @@ -474,7 +473,7 @@ for (j=0; j #include #include @@ -23,6 +20,9 @@ using namespace std; #include "vx_cal.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -30,7 +30,9 @@ int date_to_mjd(int month, int day, int year) { -int g, b, answer; +int g; +int b; +int answer; b = (month - 14)/12; @@ -42,7 +44,7 @@ b = month - 2 - 12*b; answer = (1461*(g - 100))/4 + (367*b)/12 - (3*(g/100))/4 + day - 2432076; -return ( answer ); +return answer; } diff --git a/src/basic/vx_cal/day_of_week.cc b/src/basic/vx_cal/day_of_week.cc index d8a5121d9d..a1fa8145ad 100644 --- a/src/basic/vx_cal/day_of_week.cc +++ b/src/basic/vx_cal/day_of_week.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -22,6 +19,9 @@ using namespace std; #include "vx_cal.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -39,7 +39,7 @@ w = 1 + (w + 2)%7; // 1 = Mon, 2 = Tue, 3 = Wed, 4 = Thu, 5 = Fri, 6 = Sat, 7 = Sun // -return ( w ); +return w; } diff --git a/src/basic/vx_cal/doyhms_to_unix.cc b/src/basic/vx_cal/doyhms_to_unix.cc index 39bc298d10..67993a4f15 100644 --- a/src/basic/vx_cal/doyhms_to_unix.cc +++ b/src/basic/vx_cal/doyhms_to_unix.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -22,6 +19,14 @@ using namespace std; #include "vx_cal.h" +using namespace std; + + +//////////////////////////////////////////////////////////////////////// + +constexpr int sec_per_day = 60 * 60 * 24; +constexpr int day_per_year = 365; + //////////////////////////////////////////////////////////////////////// @@ -30,7 +35,9 @@ unixtime doyhms_to_unix(int doy, int year, int hour, int minute, int second) { unixtime answer; -int mjd, month, day; +int mjd; +int month; +int day; mjd = date_to_mjd(1, 0, year) + doy; @@ -40,7 +47,7 @@ mjd_to_date(mjd, month, day, year); answer = mdyhms_to_unix(month, day, year, hour, minute, second); -return ( answer ); +return answer; } @@ -77,7 +84,7 @@ int out_sec; out_sec = hour*3600 + minute*60 + second; -return ( out_sec ); +return out_sec; } @@ -87,13 +94,19 @@ return ( out_sec ); int unix_to_sec_of_day(unixtime u) { -int s, mon, day, yr, hr, min, sec; +int s; +int mon; +int day; +int yr; +int hr; +int min; +int sec; unix_to_mdyhms(u, mon, day, yr, hr, min, sec); s = hms_to_sec(hr, min, sec); -return ( s ); +return s; } @@ -103,13 +116,16 @@ return ( s ); int unix_to_day_of_year(unixtime u) { -int mon, day, yr, hr, min, sec; +int mon; +int day; +int yr; +int hr; +int min; +int sec; unix_to_mdyhms(u, mon, day, yr, hr, min, sec); -int sec_of_year = mdyhms_to_unix(mon, day, 1970, 0, 0, 0); - -int sec_per_day = 60 * 60 * 24; +int sec_of_year = (int)mdyhms_to_unix(mon, day, 1970, 0, 0, 0); return ( sec_of_year / sec_per_day ); @@ -121,14 +137,19 @@ return ( sec_of_year / sec_per_day ); long unix_to_long_yyyymmddhh(unixtime u) { -int mon, day, yr, hr, min, sec; +int mon; +int day; +int yr; +int hr; +int min; +int sec; long yyyymmddhh; unix_to_mdyhms(u, mon, day, yr, hr, min, sec); yyyymmddhh = 1000000 * yr + 10000 * mon + 100 * day + hr; -return ( yyyymmddhh ); +return yyyymmddhh; } @@ -138,8 +159,6 @@ return ( yyyymmddhh ); int sec_of_day_diff(unixtime ut1, unixtime ut2) { -int sec_per_day = 60 * 60 * 24; - int s1 = unix_to_sec_of_day(ut1); int s2 = unix_to_sec_of_day(ut2); @@ -149,7 +168,7 @@ int dt = s2 - s1; if ( dt < -1 * sec_per_day/2 ) dt += sec_per_day; else if ( dt > sec_per_day/2 ) dt -= sec_per_day; -return ( dt ); +return dt; } @@ -160,9 +179,6 @@ return ( dt ); int day_of_year_diff(unixtime ut1, unixtime ut2) { -int sec_per_day = 60 * 60 * 24; -int day_per_year = 365; - int d1 = unix_to_day_of_year(ut1); int d2 = unix_to_day_of_year(ut2); @@ -172,7 +188,7 @@ int dt = d2 - d1; if ( dt < -1 * day_per_year/2.0 ) dt += day_per_year; else if ( dt > day_per_year/2.0 ) dt -= day_per_year; -return ( dt ); +return dt; } diff --git a/src/basic/vx_cal/is_dst.cc b/src/basic/vx_cal/is_dst.cc index d142481bb1..fbe41e58a0 100644 --- a/src/basic/vx_cal/is_dst.cc +++ b/src/basic/vx_cal/is_dst.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -22,6 +19,9 @@ using namespace std; #include "vx_cal.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -69,8 +69,12 @@ int is_dst(int month, int day, int year, int hour, int minute, int second) { -int mjd0, ly, year_type; -unixtime T, dst_start, dst_stop; +int mjd0; +int ly; +int year_type; +unixtime T; +unixtime dst_start; +unixtime dst_stop; ly = is_leap_year(year); @@ -87,7 +91,7 @@ dst_start = mdyhms_to_unix(dst_info[year_type].month_start, dst_info[year_type].day_start, year, 2, 0, 0); -if ( T < dst_start ) return ( 0 ); +if ( T < dst_start ) return 0; @@ -95,11 +99,11 @@ dst_stop = mdyhms_to_unix(dst_info[year_type].month_stop, dst_info[year_type].day_stop, year, 2, 0, 0); -if ( T > dst_stop ) return ( 0 ); +if ( T > dst_stop ) return 0; -return ( 1 ); +return 1; } @@ -112,13 +116,18 @@ int is_dst(unixtime T) { int a; -int month, day, year, hour, minute, second; +int month; +int day; +int year; +int hour; +int minute; +int second; unix_to_mdyhms(T, month, day, year, hour, minute, second); a = is_dst(month, day, year, hour, minute, second); -return ( a ); +return a; } diff --git a/src/basic/vx_cal/is_leap_year.cc b/src/basic/vx_cal/is_leap_year.cc index 4dde4de925..1cd567a0ae 100644 --- a/src/basic/vx_cal/is_leap_year.cc +++ b/src/basic/vx_cal/is_leap_year.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -24,6 +21,9 @@ using namespace std; #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -34,14 +34,14 @@ int is_leap_year(int year) year = abs(year); -if ( year%4 ) return ( 0 ); +if ( year%4 ) return 0; -if ( year%100 ) return ( 1 ); +if ( year%100 ) return 1; -if ( year%400 ) return ( 0 ); +if ( year%400 ) return 0; -return ( 1 ); +return 1; } @@ -92,12 +92,17 @@ void increase_one_month(int &year, int &month) { #define SEC_MONTH (86400*30) #define SEC_YEAR (86400*30*12) -#define DAY_EPSILON 0.00002 +static const double DAY_EPSILON = 0.00002; unixtime add_to_unixtime(unixtime base_unixtime, int sec_per_unit, double time_value, bool no_leap) { + int month; + int day; + int year; + int hour; + int minute; + int second; unixtime ut; - int month, day, year, hour, minute, second; unixtime time_value_ut = (unixtime)time_value; double time_fraction = time_value - time_value_ut; const char *method_name = "add_to_unixtime() -->"; @@ -117,10 +122,10 @@ unixtime add_to_unixtime(unixtime base_unixtime, int sec_per_unit, if (sec_per_unit == SEC_YEAR) { year += time_value_ut; time_fraction *= 12; // 12 months/year - month_offset = (unixtime)time_fraction; + month_offset = (int)time_fraction; time_fraction -= month_offset; } - else month_offset = time_value_ut; + else month_offset = (int)time_value_ut; for (int idx=0; idx 0.5) day++; + day += (int)(day_offset + 0.5); } } else { day_offset = time_fraction * 30; time_value_ut = (int)day_offset; - day += time_value_ut; - if (day_offset - time_value_ut > 0.5) day++; + day += (int)(time_value_ut + 0.5); if (day > 30) { day -= 30; increase_one_month(year, month); @@ -169,8 +172,8 @@ unixtime add_to_unixtime(unixtime base_unixtime, int sec_per_unit, // Other cases are as floating number if ((1.0 - time_fraction) < TIME_EPSILON) time_value_ut += 1; else if (time_fraction > TIME_EPSILON) use_ut = false; - if (use_ut) ut = (unixtime)(base_unixtime + sec_per_unit * time_value_ut); - else ut = (unixtime)(base_unixtime + sec_per_unit * time_value); + if (use_ut) ut = base_unixtime + sec_per_unit * time_value_ut; + else ut = base_unixtime + (unixtime)(sec_per_unit * time_value); } else { // no_leap year && unit = day unix_to_mdyhms(base_unixtime, month, day, year, hour, minute, second); @@ -190,8 +193,8 @@ unixtime add_to_unixtime(unixtime base_unixtime, int sec_per_unit, day = day_offset; if (day == 0) day = 1; ut = mdyhms_to_unix(month, day, year, hour, minute, second); - if (time_fraction > (1-TIME_EPSILON) ) ut += sec_per_unit; - else if (time_fraction > TIME_EPSILON) ut += (time_fraction * sec_per_unit); + if (time_fraction > (1-TIME_EPSILON) ) ut += (unixtime)sec_per_unit; + else if (time_fraction > TIME_EPSILON) ut += (unixtime)(time_fraction * sec_per_unit); } mlog << Debug(5) << method_name << unix_to_yyyymmdd_hhmmss(base_unixtime) diff --git a/src/basic/vx_cal/mdyhms_to_unix.cc b/src/basic/vx_cal/mdyhms_to_unix.cc index 23b9a8b2f6..8d59bba64a 100644 --- a/src/basic/vx_cal/mdyhms_to_unix.cc +++ b/src/basic/vx_cal/mdyhms_to_unix.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -22,6 +19,9 @@ using namespace std; #include "vx_cal.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -29,7 +29,10 @@ unixtime mdyhms_to_unix(int month, int day, int year, int hour, int minute, int { -unixtime b, g, mjd, answer; +unixtime b; +unixtime g; +unixtime mjd; +unixtime answer; b = (month - 14)/12; @@ -43,7 +46,7 @@ mjd = (1461*(g - 100))/4 + (367*b)/12 - (3*(g/100))/4 + day - 2432076; answer = 86400*(mjd - 40587) + 3600*hour + 60*minute + second; -return ( answer ); +return answer; } diff --git a/src/basic/vx_cal/time_array.cc b/src/basic/vx_cal/time_array.cc index 0cc068d350..c49ad9a7d8 100644 --- a/src/basic/vx_cal/time_array.cc +++ b/src/basic/vx_cal/time_array.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -23,6 +21,9 @@ using namespace std; #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -82,11 +83,11 @@ TimeArray & TimeArray::operator=(const TimeArray & a) { -if ( this == &a ) return ( * this ); +if ( this == &a ) return *this; assign(a); -return ( * this ); +return *this; } @@ -98,11 +99,11 @@ bool TimeArray::operator==(const TimeArray & a) const { -if ( Nelements != a.Nelements ) return ( false ); +if ( Nelements != a.Nelements ) return false; bool status = true; -for (int j=0; j<(Nelements); ++j) { +for (int j=0; j= Nelements) ) { } -return ( e[n] ); +return e[n]; } @@ -331,15 +326,15 @@ int TimeArray::index(unixtime u) const { -int j, match = -1; +int match = -1; -for (j=0; j u) u = e[j]; } -return(u); +return u; } @@ -490,14 +481,12 @@ ConcatString TimeArray::serialize() const ConcatString s; - if(n_elements() == 0) return(s); - - int j; + if(n_elements() == 0) return s; s << e[0]; - for(j=1; j= Nelements || // Store subset for(int i=beg; i<=end; i++) subset_ta.add(e[i]); -return ( subset_ta ); +return subset_ta; } @@ -602,12 +592,12 @@ const unixtime *a = (const unixtime *) p1; const unixtime *b = (const unixtime *) p2; -if ( (*a) < (*b) ) return ( -1 ); +if ( (*a) < (*b) ) return -1; -if ( (*a) > (*b) ) return ( 1 ); +if ( (*a) > (*b) ) return 1; -return ( 0 ); +return 0; } @@ -627,7 +617,7 @@ for ( int i=0; i #include #include @@ -24,6 +21,9 @@ using namespace std; #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -31,7 +31,9 @@ void sec_to_hhmmss(int in_sec, ConcatString& str) { -int hour, minute, second; +int hour; +int minute; +int second; if ( in_sec == bad_data_int ) { str = na_str; @@ -64,7 +66,7 @@ ConcatString str; sec_to_hhmmss(in_sec, str); -return ( str ); +return str; } @@ -77,7 +79,9 @@ ConcatString sec_to_hhmmss_colon(int in_sec) { ConcatString s; -int hour, minute, second; +int hour; +int minute; +int second; if ( in_sec == bad_data_int ) { s = na_str; @@ -94,7 +98,7 @@ else { } } -return(s); +return s; } @@ -106,7 +110,10 @@ int hhmmss_to_sec(const char * text) { -int i, hour, minute, second; +int i; +int hour; +int minute; +int second; i = atoi(text); @@ -118,7 +125,7 @@ second = i%100; i = hms_to_sec(hour, minute, second); -return ( i ); +return i; } @@ -130,7 +137,12 @@ void unix_to_yyyymmdd_hhmmss(unixtime u, ConcatString& str) { -int year, month, day, hour, minute, second; +int year; +int month; +int day; +int hour; +int minute; +int second; unix_to_mdyhms(u, month, day, year, hour, minute, second); @@ -148,7 +160,12 @@ void unix_to_yyyymmdd_hhmmss(unixtime u, char * junk, size_t len) { -int year, month, day, hour, minute, second; +int year; +int month; +int day; +int hour; +int minute; +int second; unix_to_mdyhms(u, month, day, year, hour, minute, second); @@ -171,7 +188,7 @@ ConcatString str; unix_to_yyyymmdd_hhmmss(u, str); -return ( str ); +return str; } @@ -183,7 +200,12 @@ unixtime yyyymmdd_hhmmss_to_unix(const char * text) { -int month, day, year, hour, minute, second; +int month; +int day; +int year; +int hour; +int minute; +int second; unixtime t; char junk[32]; @@ -215,7 +237,7 @@ second = atoi(junk); t = mdyhms_to_unix(month, day, year, hour, minute, second); -return ( t ); +return t; } @@ -227,7 +249,12 @@ unixtime yyyymmddThhmmss_to_unix(const char * text) { -int month, day, year, hour, minute, second; +int month; +int day; +int year; +int hour; +int minute; +int second; unixtime t; char junk[32]; @@ -259,7 +286,7 @@ second = atoi(junk); t = mdyhms_to_unix(month, day, year, hour, minute, second); -return ( t ); +return t; } @@ -271,7 +298,10 @@ unixtime yyyymmdd_hh_to_unix(const char * text) { -int month, day, year, hour; +int month; +int day; +int year; +int hour; unixtime t; char junk[32]; @@ -300,7 +330,7 @@ hour = atoi(junk); t = mdyhms_to_unix(month, day, year, hour, 0, 0); -return ( t ); +return t; } @@ -312,7 +342,9 @@ unixtime yyyymmdd_to_unix(const char * text) { -int month, day, year; +int month; +int day; +int year; unixtime t; char junk[32]; @@ -332,7 +364,7 @@ day = atoi(junk); t = mdyhms_to_unix(month, day, year, 0, 0, 0); -return ( t ); +return t; } @@ -344,7 +376,12 @@ void unix_to_yyyymmddhh(unixtime u, ConcatString& str) { -int year, month, day, hour, minute, second; +int month; +int day; +int year; +int hour; +int minute; +int second; unix_to_mdyhms(u, month, day, year, hour, minute, second); @@ -366,7 +403,7 @@ ConcatString str; unix_to_yyyymmddhh(u, str); -return ( str ); +return str; } @@ -382,7 +419,7 @@ ConcatString str; str << text << "0000"; - return ( yyyymmddhhmmss_to_unix(str.c_str()) ); +return yyyymmddhhmmss_to_unix(str.c_str()); } @@ -397,7 +434,7 @@ ConcatString str; str << text << "00"; - return ( yyyymmddhhmmss_to_unix(str.c_str()) ); +return yyyymmddhhmmss_to_unix(str.c_str()); } @@ -408,7 +445,12 @@ unixtime yyyymmddhhmmss_to_unix(const char * text) { -int month, day, year, hour, minute, second; +int month; +int day; +int year; +int hour; +int minute; +int second; unixtime t; char junk[32]; @@ -439,7 +481,7 @@ second = atoi(junk); t = mdyhms_to_unix(month, day, year, hour, minute, second); -return ( t ); +return t; } @@ -459,11 +501,11 @@ if ( first > last ) { } -int j, n; +int n; n = last - first + 1; -for (j=0; j #include #include @@ -24,6 +21,9 @@ using namespace std; #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -46,7 +46,7 @@ if ( j != 1 ) { } -return ( t ); +return t; } @@ -62,7 +62,7 @@ ConcatString junk; junk.format("%lld", t); -return ( junk ); +return junk; } diff --git a/src/basic/vx_config/calculator.cc b/src/basic/vx_config/calculator.cc index deda926e4d..d3e10d1566 100644 --- a/src/basic/vx_config/calculator.cc +++ b/src/basic/vx_config/calculator.cc @@ -15,8 +15,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -26,6 +24,9 @@ using namespace std; #include "celltype_to_string.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -83,14 +84,14 @@ Calculator & Calculator::operator=(const Calculator & c) { -if ( this == &c ) return ( * this ); +if ( this == &c ) return *this; NumberStack::operator=(c); dict_stack = c.dict_stack; -return ( * this ); +return *this; } @@ -119,7 +120,8 @@ void Calculator::do_add() { -Number a, b; +Number a; +Number b; Number result; @@ -151,7 +153,8 @@ void Calculator::do_subtract() { -Number a, b; +Number a; +Number b; Number result; @@ -183,7 +186,8 @@ void Calculator::do_multiply() { -Number a, b; +Number a; +Number b; Number result; @@ -215,7 +219,8 @@ void Calculator::do_divide() { -Number a, b; +Number a; +Number b; Number result; @@ -266,7 +271,8 @@ void Calculator::do_power() { -Number a, b; +Number a; +Number b; Number result; @@ -418,10 +424,9 @@ void Calculator::do_builtin(int which, const Number * n) { -int j; const BuiltinInfo & info = binfo[which]; -for (j=0; j<(info.n_args); ++j) push(n[j]); +for (int j=0; j<(info.n_args); ++j) push(n[j]); do_builtin(which); @@ -437,7 +442,8 @@ void Calculator::do_builtin_1_arg(const BuiltinInfo & info) { -Number a, result; +Number a; +Number result; a = pop(); @@ -463,7 +469,8 @@ if ( (info.i1) && (a.is_int) ) { // nope, do a double // -double x, y; +double x; +double y; x = as_double(a); @@ -491,7 +498,8 @@ void Calculator::do_builtin_2_arg(const BuiltinInfo & info) { -Number a, b; +Number a; +Number b; Number result; @@ -520,12 +528,10 @@ if ( (info.i2) && (a.is_int) && (b.is_int) ) { // nope, do a double // -double x, y, z; - -x = as_double(a); -y = as_double(b); +double x = as_double(a); +double y = as_double(b); -z = info.d2(x, y); +double z = info.d2(x, y); set_double(result, z); @@ -549,7 +555,6 @@ void Calculator::do_user_func(const DictionaryEntry * cur_e) { -int j; Number locals [max_user_function_args]; const int n_args = cur_e->n_args(); @@ -559,7 +564,7 @@ const int n_args = cur_e->n_args(); // we just need to pop them off and load them in to the local vars // -for (j=0; j #include #include @@ -30,6 +28,9 @@ using namespace std; #include "config_constants.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -256,7 +257,7 @@ ConcatString MetConfig::get_tmp_dir() else tmp_dir = default_tmp_dir; } - return ( tmp_dir ); + return tmp_dir; } @@ -276,7 +277,7 @@ int MetConfig::nc_compression() if ( !LastLookupStatus ) n = default_nc_compression; } - return ( n ); + return n; } //////////////////////////////////////////////////////////////////////// @@ -289,7 +290,7 @@ int n = lookup_int(conf_key_output_precision, false); if ( !LastLookupStatus ) n = default_precision; -return ( n ); +return n; } @@ -318,7 +319,7 @@ temp_filename = make_temp_file_name(temp_filename.c_str(), 0); recursive_envs(name, temp_filename.c_str()); -bison_input_filename = (const char *) temp_filename.c_str(); +bison_input_filename = temp_filename.c_str(); dict_stack = &DS; @@ -348,13 +349,13 @@ parse_status = configparse(); if ( configin ) { fclose(configin); - configin = (FILE *) 0; + configin = (FILE *) nullptr; } if ( parse_status != 0 ) { - return ( false ); + return false; } @@ -380,9 +381,9 @@ if ( DS.n_elements() != 1 ) { patch_parents(); -bison_input_filename = (const char *) 0; +bison_input_filename = (const char *) nullptr; -dict_stack = (DictionaryStack *) 0; +dict_stack = (DictionaryStack *) nullptr; LineNumber = 1; @@ -394,7 +395,7 @@ set_exit_on_warning(); unlink(temp_filename.c_str()); -return ( true ); +return true; } @@ -424,7 +425,7 @@ ofstream out; ConcatString temp_filename = get_tmp_dir(); temp_filename << "/" << "met_config"; -temp_filename = make_temp_file_name(temp_filename.c_str(), 0); +temp_filename = make_temp_file_name(temp_filename.c_str(), nullptr); out.open(temp_filename.c_str()); @@ -446,7 +447,7 @@ bool status = read(temp_filename.c_str()); remove_temp_file(temp_filename); -return ( status ); +return status; } @@ -458,13 +459,13 @@ const DictionaryEntry * MetConfig::lookup(const char * name) { -const DictionaryEntry * _e = (const DictionaryEntry *) 0; +const DictionaryEntry * _e = (const DictionaryEntry *) nullptr; _e = Dictionary::lookup(name); -LastLookupStatus = (_e != 0); +LastLookupStatus = (_e != nullptr); -return ( _e ); +return _e; } @@ -476,7 +477,7 @@ const DictionaryEntry * MetConfig::lookup(const char * name, const ConfigObjectT { -const DictionaryEntry * _e = (const DictionaryEntry *) 0; +const DictionaryEntry * _e = (const DictionaryEntry *) nullptr; _e = Dictionary::lookup(name); @@ -484,11 +485,11 @@ if ( !_e || (_e->type() != expected_type) ) { LastLookupStatus = false; - _e = 0; + _e = nullptr; } -return ( _e ); +return _e; } @@ -574,7 +575,8 @@ bool replace_env(string & line) { -size_t pos1, pos2; +size_t pos1; +size_t pos2; string out; // @@ -593,7 +595,7 @@ if ( (pos1 = line.find("//")) != string::npos ) { pos1 = line.find("${"); -if ( pos1 == string::npos ) return ( false ); +if ( pos1 == string::npos ) return false; // // replace the environment variable @@ -609,7 +611,7 @@ if ( (pos2 = line.find('}', pos1)) == string::npos ) { } string env; -char * env_value = 0; +char * env_value = nullptr; env = line.substr(pos1 + 2, pos2 - pos1 - 2); @@ -637,7 +639,7 @@ out += line.substr(pos2 + 1); line = out; -return ( true ); +return true; } diff --git a/src/basic/vx_config/config_funcs.cc b/src/basic/vx_config/config_funcs.cc index 2da959d7e7..7419761953 100644 --- a/src/basic/vx_config/config_funcs.cc +++ b/src/basic/vx_config/config_funcs.cc @@ -14,8 +14,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -26,6 +24,9 @@ using namespace std; #include "configobjecttype_to_string.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -85,11 +86,11 @@ UserFunc_1Arg & UserFunc_1Arg::operator=(const UserFunc_1Arg & f) { -if ( this == &f ) return ( * this ); +if ( this == &f ) return *this; assign(f); -return ( * this ); +return *this; } @@ -198,7 +199,7 @@ hp.run( V, &n); n = hp.pop(); -return ( as_double(n) ); +return as_double(n); } @@ -256,11 +257,11 @@ UserFunc_MultiArg & UserFunc_MultiArg::operator=(const UserFunc_MultiArg & f) { -if ( this == &f ) return ( * this ); +if ( this == &f ) return *this; assign(f); -return ( * this ); +return *this; } @@ -361,7 +362,7 @@ Number UserFunc_MultiArg::operator()(const Number * n) const hp.run( V, n); -return ( hp.pop() ); +return hp.pop(); } diff --git a/src/basic/vx_config/configobjecttype_to_string.cc b/src/basic/vx_config/configobjecttype_to_string.cc index 4bf98a16a6..facee7dfda 100644 --- a/src/basic/vx_config/configobjecttype_to_string.cc +++ b/src/basic/vx_config/configobjecttype_to_string.cc @@ -24,14 +24,14 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include "configobjecttype_to_string.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -63,7 +63,7 @@ switch ( t ) { } // switch -return ( ConcatString (s) ); +return ConcatString (s); } diff --git a/src/basic/vx_config/grdfiletype_to_string.cc b/src/basic/vx_config/grdfiletype_to_string.cc index bdeaa2bf52..8c192183a1 100644 --- a/src/basic/vx_config/grdfiletype_to_string.cc +++ b/src/basic/vx_config/grdfiletype_to_string.cc @@ -24,14 +24,14 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include "grdfiletype_to_string.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -64,7 +64,7 @@ switch ( t ) { } // switch -return ( ConcatString (s) ); +return ConcatString (s); } @@ -93,7 +93,7 @@ else if ( strcmp(text, "FileType_Python_Xarray" ) == 0 ) { t = FileType_Python // nope // -return ( false ); +return false; } diff --git a/src/basic/vx_config/icode.cc b/src/basic/vx_config/icode.cc index 6dc7e2e600..bc8d8aadc7 100644 --- a/src/basic/vx_config/icode.cc +++ b/src/basic/vx_config/icode.cc @@ -14,9 +14,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -31,6 +28,9 @@ using namespace std; #include "celltype_to_string.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -90,13 +90,13 @@ IcodeCell & IcodeCell::operator=(const IcodeCell & icc) { -if ( this == &icc ) return ( * this ); +if ( this == &icc ) return *this; assign(icc); -return ( * this ); +return *this; } @@ -137,9 +137,9 @@ i = 0; d = 0.0; -if ( name ) { delete [] name; name = (char *) 0; } +if ( name ) { delete [] name; name = (char *) nullptr; } -if ( text ) { delete [] text; text = (char *) 0; } +if ( text ) { delete [] text; text = (char *) nullptr; } e = 0; @@ -262,7 +262,7 @@ switch ( type ) { } // switch -return ( x ); +return x; } @@ -287,7 +287,7 @@ switch ( type ) { } // switch -return ( k ); +return k; } @@ -578,13 +578,13 @@ IcodeVector & IcodeVector::operator=(const IcodeVector & i) { -if ( this == &i ) return ( *this ); +if ( this == &i ) return *this; assign(i); -return ( *this ); +return *this; } @@ -621,9 +621,7 @@ extend(i.Ncells); Ncells = i.Ncells; -int j; - -for (j=0; j= Ncells) ) { } -return ( Cell[n] ); +return Cell[n]; } @@ -742,7 +740,7 @@ if ( (n < 0) || (n >= Ncells) ) { } -return ( Cell[n] ); +return Cell[n]; } @@ -867,9 +865,9 @@ bool IcodeVector::is_mark() const { -if ( Ncells != 1 ) return ( false ); +if ( Ncells != 1 ) return false; -return ( Cell[0].is_mark() ); +return Cell[0].is_mark(); } @@ -881,9 +879,9 @@ bool IcodeVector::is_mark(int k) const { -if ( Ncells != 1 ) return ( false ); +if ( Ncells != 1 ) return false; -return ( Cell[0].is_mark(k) ); +return Cell[0].is_mark(k); } @@ -895,9 +893,9 @@ bool IcodeVector::is_numeric() const { -if ( Ncells != 1 ) return ( false ); +if ( Ncells != 1 ) return false; -return ( Cell[0].is_numeric() ); +return Cell[0].is_numeric(); } @@ -953,13 +951,13 @@ CellStack & CellStack::operator=(const CellStack & c) { -if ( this == &c ) return ( *this ); +if ( this == &c ) return *this; assign(c); -return ( *this ); +return *this; } @@ -1040,7 +1038,7 @@ if ( Depth <= 0 ) { } -return ( cell[--Depth] ); +return cell[--Depth]; } @@ -1061,7 +1059,7 @@ if ( Depth <= 0 ) { } -return ( cell[Depth - 1] ); +return cell[Depth - 1]; } @@ -1082,7 +1080,7 @@ if ( Depth <= 0 ) { } -return ( cell[Depth - 1].type ); +return cell[Depth - 1].type; } @@ -1118,12 +1116,11 @@ void CellStack::dump(ostream & out, int indent_depth) const { -int j; Indent prefix(indent_depth); out << prefix << "Depth = " << Depth << '\n'; -for (j=(Depth - 1); j>=0; --j) { +for (int j=(Depth - 1); j>=0; --j) { out << prefix << "Level = " << j << '\n'; @@ -1158,9 +1155,7 @@ ICVStack::ICVStack() { -int j; - -for (j=0; j= Nelements) ) { } -return ( v[k] ); +return v[k]; } diff --git a/src/basic/vx_config/idstack.cc b/src/basic/vx_config/idstack.cc index d57ba978ad..b18b961262 100644 --- a/src/basic/vx_config/idstack.cc +++ b/src/basic/vx_config/idstack.cc @@ -15,9 +15,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -27,6 +24,9 @@ using namespace std; #include "idstack.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -84,11 +84,11 @@ Identifier & Identifier::operator=(const Identifier & i) { -if ( this == &i ) return ( * this ); +if ( this == &i ) return *this; assign(i); -return ( * this ); +return *this; } @@ -220,11 +220,11 @@ IdentifierQueue & IdentifierQueue::operator=(const IdentifierQueue & iq) { -if ( this == &iq ) return ( * this ); +if ( this == &iq ) return *this; assign(iq); -return ( * this ); +return *this; } @@ -252,9 +252,7 @@ void IdentifierQueue::clear() { -int j; - -for (j=0; j Nalloc) extend(a.Nelements); Nelements = a.Nelements; -for (j=0; j n ) return; -int j, k; +int k; Identifier * inew = (Identifier *) 0; @@ -515,7 +505,7 @@ if ( !inew ) { } -for (j=0; j= Nelements) ) { } -return ( i[k] ); +return i[k]; } @@ -572,13 +562,12 @@ void IdentifierArray::dump(ostream & out, int indent_depth) const { -int j; Indent prefix(indent_depth); out << prefix << "Nelements = " << Nelements << "\n"; -for (j=0; j #include #include @@ -36,6 +33,9 @@ using namespace std; #include "config.tab.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -209,7 +209,7 @@ while ( 1 ) { // // cout << "\n\n" << flush; -return ( t ); +return t; } @@ -381,7 +381,7 @@ if ( is_id() ) { t = do_id(); return ( token(t) ); } -return ( skip ); +return skip; } @@ -450,16 +450,16 @@ bool char_ok(int c) const int k = char_class[c]; -if ( k == char_class_digit ) return ( true ); +if ( k == char_class_digit ) return true; -if ( k == char_class_alpha ) return ( true ); +if ( k == char_class_alpha ) return true; -if ( k == char_class_sign ) return ( true ); +if ( k == char_class_sign ) return true; -if ( c == '.' ) return ( true ); +if ( c == '.' ) return true; -return ( false ); +return false; } @@ -473,7 +473,7 @@ bool is_int() bool status = is_int((char *) lexeme, max_id_length); -return ( status ); +return status; } @@ -487,7 +487,7 @@ bool is_float_v2 () bool status = is_float_v2((char *) lexeme, max_id_length); -return ( status ); +return status; } @@ -499,21 +499,21 @@ bool is_id() { -if ( char_class[lexeme[0]] != char_class_alpha ) return ( false ); +if ( char_class[lexeme[0]] != char_class_alpha ) return false; -int j, k; +int k; -for (j=0; jis_number()) && (! is_lhs) ) { set_int(configlval.nval, e->i_value()); - return ( INTEGER ); + return INTEGER; } else { set_double(configlval.nval, e->d_value()); - return ( FLOAT ); + return FLOAT; } @@ -607,7 +607,7 @@ if ( e && (! is_lhs) && (e->type() == UserFunctionType) ) { configlval.entry = e; - return ( USER_FUNCTION ); + return USER_FUNCTION; } @@ -621,7 +621,7 @@ for (j=0; j= max_id_length ) { configtext[pos++] = (char) c; -return ( c ); +return c; } @@ -1103,7 +1103,7 @@ int token(int t) // else cout << "(nul)\n"; // cout.flush(); -return ( t ); +return t; } @@ -1143,7 +1143,7 @@ else { // done // -return ( return_value ); +return return_value; } @@ -1158,7 +1158,7 @@ int do_fort_thresh() const char *method_name = "do_fort_thresh() -> "; m_strncpy(configlval.text, configtext, sizeof(configlval.text), method_name); -return ( FORTRAN_THRESHOLD ); +return FORTRAN_THRESHOLD; } @@ -1238,7 +1238,7 @@ for (j=0; j #include #include @@ -30,6 +27,9 @@ using namespace std; #include "number_stack.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -94,7 +94,7 @@ if ( this == &a ) return ( * this ); assign(a); -return ( * this ); +return *this; } @@ -378,7 +378,7 @@ if ( Nelements <= 0 ) { } -return ( e[Nelements - 1] ); +return e[Nelements - 1]; } diff --git a/src/basic/vx_config/temp_file.cc b/src/basic/vx_config/temp_file.cc index 11d2d4e55f..98683a1c5b 100644 --- a/src/basic/vx_config/temp_file.cc +++ b/src/basic/vx_config/temp_file.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,6 +19,8 @@ using namespace std; #include "file_exists.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// ConcatString make_temp_file_name(const char *prefix, const char *suffix) { @@ -59,7 +59,7 @@ ConcatString make_temp_file_name(const char *prefix, const char *suffix) { } while(file_exists(s.c_str())); - return(s); + return s; } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_config/threshold.cc b/src/basic/vx_config/threshold.cc index 5194d2cfbe..da057355e3 100644 --- a/src/basic/vx_config/threshold.cc +++ b/src/basic/vx_config/threshold.cc @@ -8,7 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -27,6 +26,9 @@ using namespace std; #include "is_bad_data.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -121,7 +123,7 @@ bool Or_Node::check(double x) const { -return ( check(x, bad_data_double, bad_data_double) ); +return check(x, bad_data_double, bad_data_double); } @@ -135,11 +137,11 @@ bool Or_Node::check(double x, double cmn, double csd) const const bool tf_left = left_child->check(x, cmn, csd); -if ( tf_left ) return ( true ); +if ( tf_left ) return true; const bool tf_right = right_child->check(x, cmn, csd); -return ( tf_right ); +return tf_right; } @@ -158,7 +160,7 @@ if ( right_child ) n->right_child = right_child->copy(); n->threshnode_assign(this); -return ( n ); +return n; } @@ -189,7 +191,7 @@ if ( !is_bad_data(prob_left) && !is_bad_data(prob_right) ) { } -return ( prob ); +return prob; } @@ -356,7 +358,7 @@ bool And_Node::check(double x, double cmn, double csd) const const bool tf_left = left_child->check(x, cmn, csd); -if ( ! tf_left ) return ( false ); +if ( ! tf_left ) return false; const bool tf_right = right_child->check(x, cmn, csd); @@ -379,7 +381,7 @@ if ( right_child ) n->right_child = right_child->copy(); n->threshnode_assign(this); -return ( n ); +return n; } @@ -428,7 +430,7 @@ if ( !is_bad_data(prob_left) && !is_bad_data(prob_right) ) { } } -return ( prob ); +return prob; } @@ -580,7 +582,7 @@ bool Not_Node::check(double x) const { -return ( check(x, bad_data_double, bad_data_double) ); +return check(x, bad_data_double, bad_data_double); } @@ -612,7 +614,7 @@ if ( child ) n->child = child->copy(); n->threshnode_assign(this); -return ( n ); +return n; } @@ -629,7 +631,7 @@ double prob_child = child->climo_prob(); if ( !is_bad_data(prob_child) ) prob = 1.0 - prob_child; -return ( prob ); +return prob; } @@ -650,7 +652,7 @@ if ( !child ) { } -return ( child->need_perc() ); +return child->need_perc(); } @@ -782,7 +784,7 @@ bool Simple_Node::check(double x) const { -return ( check(x, bad_data_double, bad_data_double) ); +return check(x, bad_data_double, bad_data_double); } @@ -860,7 +862,7 @@ switch ( op ) { } // switch -return ( tf ); +return tf; } @@ -884,7 +886,7 @@ n->Ptype = Ptype; n->threshnode_assign(this); -return ( n ); +return n; } @@ -1258,7 +1260,7 @@ if ( Ptype == perc_thresh_climo_dist ) { } // switch } -return ( prob ); +return prob; } @@ -1373,7 +1375,7 @@ if ( this == &c ) return ( * this ); assign(c); -return ( * this ); +return *this; } @@ -1715,7 +1717,7 @@ ConcatString t; if ( node ) t = node->s; else t = na_str; -return(t); +return t; } @@ -1736,7 +1738,7 @@ ConcatString t; if ( node ) t = node->abbr_s; else t = na_str; -return(t); +return t; } @@ -1798,7 +1800,7 @@ bool SingleThresh::check(double x) const { -return ( check(x, bad_data_double, bad_data_double) ); +return check(x, bad_data_double, bad_data_double); }