Skip to content

Commit

Permalink
#2521 Move #include statement to the top of the file and removed thes…
Browse files Browse the repository at this point in the history
…e useless parentheses
  • Loading branch information
Howard Soh committed May 10, 2023
1 parent ed9a5e6 commit 3138e3c
Show file tree
Hide file tree
Showing 23 changed files with 520 additions and 471 deletions.
17 changes: 8 additions & 9 deletions src/basic/enum_to_string/enum_to_string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ static const int debug = 0;
////////////////////////////////////////////////////////////////////////


using namespace std;

#include <iostream>
#include <unistd.h>

Expand All @@ -35,6 +33,9 @@ using namespace std;
#include "enum_to_string.h"


using namespace std;


////////////////////////////////////////////////////////////////////////


Expand Down Expand Up @@ -157,7 +158,7 @@ if ( parse_status != 0 ) {

}

return ( 0 );
return 0;

}

Expand All @@ -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<argc; ++j) {
for (int j=1; j<argc; ++j) {

if ( argv[j][0] == '-' ) { found = 1; break; }

Expand Down Expand Up @@ -217,9 +218,7 @@ void shift_down(int &argc, char **argv, int pos, int shift)

{

int j;

for (j=pos; j<(argc - shift); ++j) argv[j] = argv[j + shift];
for (int j=pos; j<(argc - shift); ++j) argv[j] = argv[j + shift];

argc -= shift;

Expand Down Expand Up @@ -396,7 +395,7 @@ int yywrap()

{

return ( 1 );
return 1;

}

Expand Down
49 changes: 25 additions & 24 deletions src/basic/enum_to_string/my_enum_scanner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
////////////////////////////////////////////////////////////////////////


using namespace std;


#include <iostream>
#include <unistd.h>
#include <stdlib.h>
Expand All @@ -22,6 +19,10 @@ using namespace std;

#include "str_wrappers.h"


using namespace std;


////////////////////////////////////////////////////////////////////////


Expand Down Expand Up @@ -155,7 +156,7 @@ while ( 1 ) {
//
// cout << "\n\n" << flush;

return ( t );
return t;

}

Expand Down Expand Up @@ -266,7 +267,7 @@ if ( is_id() ) { if ( do_id() ) return ( token(ID) ); }



return ( skip );
return skip;

}

Expand Down Expand Up @@ -330,7 +331,7 @@ if ( k == char_class_digit ) return ( true );
if ( k == char_class_alpha ) return ( true );


return ( false );
return false;

}

Expand Down Expand Up @@ -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<max_lexeme_size; ++j) {
for (int j=0; j<max_lexeme_size; ++j) {

if ( lexeme[j] == 0 ) break;

Expand Down Expand Up @@ -438,13 +439,13 @@ if ( enum_mode || last_was_enum || last_was_class ) {

m_strncpy(yylval.name, yytext, sizeof(yylval.name), method_name);

return ( 1 );
return 1;

}



return ( 0 );
return 0;

}

Expand All @@ -456,13 +457,13 @@ int do_int()

{

if ( !enum_mode ) return ( 0 );
if ( !enum_mode ) return 0;

yylval.ival = atoi(yytext);



return ( 1 );
return 1;

}

Expand All @@ -478,14 +479,14 @@ int do_left_curly()

++column;

if ( !enum_mode ) return ( 0 );
if ( !enum_mode ) return 0;

yylval.ival = bracket_level;

lexeme[0] = '{';


return ( 1 );
return 1;

}

Expand All @@ -503,14 +504,14 @@ int do_right_curly()

ss.clear_to_level(bracket_level);

if ( !enum_mode ) return ( 0 );
if ( !enum_mode ) return 0;

yylval.ival = bracket_level + 1;

lexeme[0] = '}';


return ( 1 );
return 1;

}

Expand All @@ -528,13 +529,13 @@ if ( enum_mode ) {

lexeme[0] = '}';

return ( 1 );
return 1;

}



return ( 0 );
return 0;

}

Expand All @@ -552,12 +553,12 @@ if ( enum_mode ) {

lexeme[0] = '=';

return ( 1 );
return 1;

}


return ( 0 );
return 0;

}

Expand All @@ -575,12 +576,12 @@ if ( enum_mode ) {

lexeme[0] = ',';

return ( 1 );
return 1;

}


return ( 0 );
return 0;

}

Expand Down Expand Up @@ -669,7 +670,7 @@ if ( c == '\n' ) {
}


return ( c );
return c;

}

Expand All @@ -691,7 +692,7 @@ if ( t == CLASS ) last_was_class = 1;
if ( t == ENUM ) last_was_enum = 1;


return ( t );
return t;

}

Expand Down
15 changes: 7 additions & 8 deletions src/basic/enum_to_string/scope.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
////////////////////////////////////////////////////////////////////////


using namespace std;


#include <iostream>
#include <unistd.h>
#include <stdlib.h>
Expand All @@ -23,6 +20,8 @@ using namespace std;
#include "str_wrappers.h"


using namespace std;


////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -83,7 +82,7 @@ if ( this == &e ) return ( *this );

assign(e);

return ( *this );
return *this;

}

Expand Down Expand Up @@ -239,7 +238,7 @@ if ( this == &ss ) return ( *this );

assign(ss);

return ( *this );
return *this;

}

Expand Down Expand Up @@ -313,7 +312,7 @@ if ( (pos < 0) || (pos >= N) ) {
}


return ( s[pos] );
return s[pos];

}

Expand Down Expand Up @@ -437,7 +436,7 @@ s << " level = " << (sse.level()) << "\n";

s.flush();

return ( s );
return s;

}

Expand Down Expand Up @@ -474,7 +473,7 @@ for (j=0; j<n; ++j) {
}


return ( s );
return s;

}

Expand Down
12 changes: 7 additions & 5 deletions src/basic/vx_cal/date_to_mjd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
////////////////////////////////////////////////////////////////////////


using namespace std;


#include <iostream>
#include <unistd.h>
#include <stdlib.h>
Expand All @@ -23,14 +20,19 @@ using namespace std;
#include "vx_cal.h"


using namespace std;


////////////////////////////////////////////////////////////////////////


int date_to_mjd(int month, int day, int year)

{

int g, b, answer;
int g;
int b;
int answer;


b = (month - 14)/12;
Expand All @@ -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;

}

Expand Down
8 changes: 4 additions & 4 deletions src/basic/vx_cal/day_of_week.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
////////////////////////////////////////////////////////////////////////


using namespace std;


#include <iostream>
#include <unistd.h>
#include <stdlib.h>
Expand All @@ -22,6 +19,9 @@ using namespace std;
#include "vx_cal.h"


using namespace std;


////////////////////////////////////////////////////////////////////////


Expand All @@ -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;

}

Expand Down
Loading

0 comments on commit 3138e3c

Please sign in to comment.