Skip to content

Commit aa267c8

Browse files
C++: Force LF for .c,.cpp,.h,.hpp
1 parent caf4a76 commit aa267c8

File tree

200 files changed

+5422
-5417
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+5422
-5417
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
[*.{ql,qll,qlref,dbscheme,qhelp,html,js,mjs,ts,json,yml}]
1+
[*.{ql,qll,qlref,dbscheme,qhelp,html,js,mjs,ts,json,yml,c,cpp,h,hpp}]
22
end_of_line = lf

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@
2121
*.ts eol=lf
2222
*.json eol=lf
2323
*.yml eol=lf
24+
*.c eol=lf
25+
*.cpp eol=lf
26+
*.h eol=lf
27+
*.hpp eol=lf
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
// an include declaration just adds one source dependency, it does not automatically
2-
// add a dependency from this file to all the declarations in stdio.h
3-
#include <stdio.h>
4-
#include <myfile.h> // contains non-static global myfile_err
5-
6-
extern int myfile_err; // this external declaration adds a dependency on myfile.h
7-
8-
class C {
9-
public:
10-
C() {
11-
// one dependency for printf:
12-
printf("Hello world!");
13-
// one dependency for FILE type, and one for NULL macro:
14-
FILE fp = NULL;
15-
}
16-
};
17-
1+
// an include declaration just adds one source dependency, it does not automatically
2+
// add a dependency from this file to all the declarations in stdio.h
3+
#include <stdio.h>
4+
#include <myfile.h> // contains non-static global myfile_err
5+
6+
extern int myfile_err; // this external declaration adds a dependency on myfile.h
7+
8+
class C {
9+
public:
10+
C() {
11+
// one dependency for printf:
12+
printf("Hello world!");
13+
// one dependency for FILE type, and one for NULL macro:
14+
FILE fp = NULL;
15+
}
16+
};
17+
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
//This struct contains 30 fields.
2-
struct MyParticle {
3-
bool isActive;
4-
int priority;
5-
6-
float x, y, z;
7-
float dx, dy, dz;
8-
float ddx, ddy, ddz;
9-
bool isCollider;
10-
11-
int age, maxAge;
12-
float size1, size2;
13-
14-
bool hasColor;
15-
unsigned char r1, g1, b1, a1;
16-
unsigned char r2, g2, b2, a2;
17-
18-
class texture *tex;
19-
float u1, v1, u2, v2;
20-
};
1+
//This struct contains 30 fields.
2+
struct MyParticle {
3+
bool isActive;
4+
int priority;
5+
6+
float x, y, z;
7+
float dx, dy, dz;
8+
float ddx, ddy, ddz;
9+
bool isCollider;
10+
11+
int age, maxAge;
12+
float size1, size2;
13+
14+
bool hasColor;
15+
unsigned char r1, g1, b1, a1;
16+
unsigned char r2, g2, b2, a2;
17+
18+
class texture *tex;
19+
float u1, v1, u2, v2;
20+
};
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// this example has 15 parameters.
2-
void fillRect(int x, int y, int w, int h,
3-
int r1, int g1, int b1, int a1,
4-
int r2, int g2, int b2, int a2,
5-
gradient_type grad, unsigned int flags, bool border)
6-
{
7-
// ...
8-
}
1+
// this example has 15 parameters.
2+
void fillRect(int x, int y, int w, int h,
3+
int r1, int g1, int b1, int a1,
4+
int r2, int g2, int b2, int a2,
5+
gradient_type grad, unsigned int flags, bool border)
6+
{
7+
// ...
8+
}
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
//This condition is too complex and can be improved by using local variables
2-
bool accept_message =
3-
(message_type == CONNECT && _state != CONNECTED) ||
4-
(message_type == DISCONNECT && _state == CONNECTED) ||
5-
(message_type == DATA && _state == CONNECTED);
6-
7-
//This condition is acceptable, as all the logical operators are of the same type (&&)
8-
bool valid_connect =
9-
message_type == CONNECT &&
10-
_state != CONNECTED &&
11-
time_since_prev_connect > MAX_CONNECT_INTERVAL &&
12-
message_length <= MAX_PACKET_SIZE &&
1+
//This condition is too complex and can be improved by using local variables
2+
bool accept_message =
3+
(message_type == CONNECT && _state != CONNECTED) ||
4+
(message_type == DISCONNECT && _state == CONNECTED) ||
5+
(message_type == DATA && _state == CONNECTED);
6+
7+
//This condition is acceptable, as all the logical operators are of the same type (&&)
8+
bool valid_connect =
9+
message_type == CONNECT &&
10+
_state != CONNECTED &&
11+
time_since_prev_connect > MAX_CONNECT_INTERVAL &&
12+
message_length <= MAX_PACKET_SIZE &&
1313
checksum(message) == get_checksum_field(message);
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
void f(int i) {
2-
for (int i = 0; i < 10; ++i) { //the loop variable hides the parameter to f()
3-
...
4-
}
5-
}
6-
1+
void f(int i) {
2+
for (int i = 0; i < 10; ++i) { //the loop variable hides the parameter to f()
3+
...
4+
}
5+
}
6+
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
void f() {
2-
int i = 10;
3-
4-
for (int i = 0; i < 10; i++) { //the loop counter hides the variable
5-
...
6-
}
7-
8-
{
9-
int i = 12; //this variable hides the variable in the outer block
10-
...
11-
}
12-
}
1+
void f() {
2+
int i = 10;
3+
4+
for (int i = 0; i < 10; i++) { //the loop counter hides the variable
5+
...
6+
}
7+
8+
{
9+
int i = 12; //this variable hides the variable in the outer block
10+
...
11+
}
12+
}
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
int i = 10;
2-
3-
void f() {
4-
for (int i = 0; i < 10; i++) { //the loop counter hides the global variable i
5-
...
6-
}
7-
8-
{
9-
int i = 12; //this variable hides the global variable i
10-
...
11-
}
12-
}
1+
int i = 10;
2+
3+
void f() {
4+
for (int i = 0; i < 10; i++) { //the loop counter hides the global variable i
5+
...
6+
}
7+
8+
{
9+
int i = 12; //this variable hides the global variable i
10+
...
11+
}
12+
}
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
void f(int i) {
2-
if (i == 10); //empty then block
3-
... //won't be part of the if statement
4-
5-
if (i == 12) {
6-
...
7-
} else { //empty else block, most likely a mistake
8-
}
9-
}
1+
void f(int i) {
2+
if (i == 10); //empty then block
3+
... //won't be part of the if statement
4+
5+
if (i == 12) {
6+
...
7+
} else { //empty else block, most likely a mistake
8+
}
9+
}
Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
1-
static int idctr = 0;
2-
//Basic connection with id
3-
class Connection {
4-
public:
5-
int connId;
6-
virtual void print_info() {
7-
cout << "id: " << connId << "\n";
8-
}
9-
Connection() {
10-
connId = idctr++;
11-
}
12-
};
13-
14-
//Adds counters, and an overriding print_info
15-
class MeteredConnection : public Connection {
16-
public:
17-
int txCtr;
18-
int rxCtr;
19-
MeteredConnection() {
20-
txCtr = 0;
21-
rxCtr = 0;
22-
}
23-
virtual void print_info() {
24-
cout << "id: " << connId << "\n" << "tx/rx: " << txCtr << "/" << rxCtr << "\n";
25-
}
26-
};
27-
28-
int main(int argc, char* argv[]) {
29-
Connection conn;
30-
MeteredConnection m_conn;
31-
32-
Connection curr_conn = conn;
33-
curr_conn.print_info();
34-
curr_conn = m_conn; //Wrong: Derived MetricConnection assigned to Connection
35-
//variable, will slice off the counters and the overriding print_info
36-
curr_conn.print_info(); //Will not print the counters.
37-
38-
Connection* curr_pconn = &conn;
39-
curr_pconn->print_info();
40-
curr_pconn = &m_conn; //Correct: Pointer assigned to address of the MetricConnection.
41-
//Counters and virtual functions remain intact.
42-
curr_pconn->print_info(); //Will call the correct method MeteredConnection::print_info
43-
}
1+
static int idctr = 0;
2+
//Basic connection with id
3+
class Connection {
4+
public:
5+
int connId;
6+
virtual void print_info() {
7+
cout << "id: " << connId << "\n";
8+
}
9+
Connection() {
10+
connId = idctr++;
11+
}
12+
};
13+
14+
//Adds counters, and an overriding print_info
15+
class MeteredConnection : public Connection {
16+
public:
17+
int txCtr;
18+
int rxCtr;
19+
MeteredConnection() {
20+
txCtr = 0;
21+
rxCtr = 0;
22+
}
23+
virtual void print_info() {
24+
cout << "id: " << connId << "\n" << "tx/rx: " << txCtr << "/" << rxCtr << "\n";
25+
}
26+
};
27+
28+
int main(int argc, char* argv[]) {
29+
Connection conn;
30+
MeteredConnection m_conn;
31+
32+
Connection curr_conn = conn;
33+
curr_conn.print_info();
34+
curr_conn = m_conn; //Wrong: Derived MetricConnection assigned to Connection
35+
//variable, will slice off the counters and the overriding print_info
36+
curr_conn.print_info(); //Will not print the counters.
37+
38+
Connection* curr_pconn = &conn;
39+
curr_pconn->print_info();
40+
curr_pconn = &m_conn; //Correct: Pointer assigned to address of the MetricConnection.
41+
//Counters and virtual functions remain intact.
42+
curr_pconn->print_info(); //Will call the correct method MeteredConnection::print_info
43+
}
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
void sanitize(Fields[] record) {
2-
//The number of fields here can be put in a const
3-
for (fieldCtr = 0; field < 7; field++) {
4-
sanitize(fields[fieldCtr]);
5-
}
6-
}
7-
8-
#define NUM_FIELDS 7
9-
10-
void process(Fields[] record) {
11-
//This avoids using a magic constant by using the macro instead
12-
for (fieldCtr = 0; field < NUM_FIELDS; field++) {
13-
process(fields[fieldCtr]);
14-
}
15-
}
16-
1+
void sanitize(Fields[] record) {
2+
//The number of fields here can be put in a const
3+
for (fieldCtr = 0; field < 7; field++) {
4+
sanitize(fields[fieldCtr]);
5+
}
6+
}
7+
8+
#define NUM_FIELDS 7
9+
10+
void process(Fields[] record) {
11+
//This avoids using a magic constant by using the macro instead
12+
for (fieldCtr = 0; field < NUM_FIELDS; field++) {
13+
process(fields[fieldCtr]);
14+
}
15+
}
16+
Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
class C {
2-
private:
3-
Other* other = NULL;
4-
public:
5-
C(const C& copyFrom) {
6-
Other* newOther = new Other();
7-
*newOther = copyFrom.other;
8-
this->other = newOther;
9-
}
10-
11-
//No operator=, by default will just copy the pointer other, will not create a new object
12-
};
13-
14-
class D {
15-
Other* other = NULL;
16-
public:
17-
D& operator=(D& rhs) {
18-
Other* newOther = new Other();
19-
*newOther = rhs.other;
20-
this->other = newOther;
21-
return *this;
22-
}
23-
24-
//No copy constructor, will just copy the pointer other and not create a new object
25-
};
26-
1+
class C {
2+
private:
3+
Other* other = NULL;
4+
public:
5+
C(const C& copyFrom) {
6+
Other* newOther = new Other();
7+
*newOther = copyFrom.other;
8+
this->other = newOther;
9+
}
10+
11+
//No operator=, by default will just copy the pointer other, will not create a new object
12+
};
13+
14+
class D {
15+
Other* other = NULL;
16+
public:
17+
D& operator=(D& rhs) {
18+
Other* newOther = new Other();
19+
*newOther = rhs.other;
20+
this->other = newOther;
21+
return *this;
22+
}
23+
24+
//No copy constructor, will just copy the pointer other and not create a new object
25+
};
26+

0 commit comments

Comments
 (0)