Skip to content

Commit bbc4206

Browse files
committed
fixed g++
1 parent 7c3a2ea commit bbc4206

File tree

7 files changed

+29
-29
lines changed

7 files changed

+29
-29
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ endif
66

77
SOURCE= src/main.cpp src/fileio.cpp src/formatting/global.cpp src/formatting/languages/python/formatter.cpp src/config.cpp
88
HEADER= headers/fileio.hpp headers/formatting.hpp headers/config.hpp
9-
CC = g++
10-
FLAGS= -Wall -std=c++20 -g
9+
CC = g++-11
10+
FLAGS= -Wall -std=c++17 -g
1111

1212
all: $(OBJS)
1313
$(CC) ${SOURCE} -o $(TARGET) ${FLAGS}
1414

1515
clean:
16-
rm -f $(TARGET)
16+
rm -rf $(TARGET) output.py Compactifier.out.dSYM/

config.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# =============================================================================
22
#
33
# CompactifierPlusPlus V1.0
4-
# Configuration file for the CompactifierPlusPlus
4+
# Configuration file for the CompactifierPlusPlus
55
#
66
# =============================================================================
77

src/config.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
std::vector<std::pair<std::string, std::string>> pharseConfig() {
1010
std::vector<std::string> fileContents = readFile(CONFIG_FILE);
1111
std::vector<std::pair<std::string, std::string>> config;
12-
for (int i = 0; i < fileContents.size(); i++) {
12+
for (size_t i = 0; i < fileContents.size(); i++) {
1313
if (fileContents[i][0] == '#') continue; // comments
1414
if (fileContents[i][0] == '\n') continue; // empty lines
1515
if (fileContents[i][0] == '\r') continue; // empty lines
@@ -22,7 +22,7 @@ std::vector<std::pair<std::string, std::string>> pharseConfig() {
2222
std::cout << "Config file loaded" << std::endl;
2323
// print keys loaded
2424
std::string keys;
25-
for (int i = 0; i < config.size(); i++) {
25+
for (size_t i = 0; i < config.size(); i++) {
2626
keys += config[i].first + ", ";
2727
}
2828
std::cout << "Loaded Keys: " << keys << std::endl;
@@ -31,15 +31,15 @@ std::vector<std::pair<std::string, std::string>> pharseConfig() {
3131

3232
bool checkKey(std::string key) {
3333
std::vector<std::pair<std::string, std::string>> config = pharseConfig();
34-
for (int i = 0; i < config.size(); i++) {
34+
for (size_t i = 0; i < config.size(); i++) {
3535
if (config[i].first == key) return true;
3636
}
3737
return false;
3838
}
3939

4040
std::string getValue(std::string key) {
4141
std::vector<std::pair<std::string, std::string>> config = pharseConfig();
42-
for (int i = 0; i < config.size(); i++) {
42+
for (size_t i = 0; i < config.size(); i++) {
4343
if (config[i].first == key) return config[i].second;
4444
}
4545
return "";

src/fileio.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ int fileSize(std::string file) {
3333

3434
void writeFile(std::string file, std::vector<std::string>& contents) {
3535
std::ofstream in(file);
36-
for (int i = 0; i < contents.size(); i++) {
36+
for (size_t i = 0; i < contents.size(); i++) {
3737
in << contents[i] << std::endl;
3838
}
3939
in.close();

src/formatting/global.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
#include <string>
22
#include <iostream>
33
#include <vector>
4+
#include <algorithm>
45
#include "../headers/formatting.hpp"
56

67
void removeSingleAnn(std::vector<std::string> &fileContents, std::string ann) {
7-
for (int i = 0; i < fileContents.size(); i++) {
8-
if (fileContents[i].find(ann) != -1) {
8+
for (size_t i = 0; i < fileContents.size(); i++) {
9+
if (fileContents[i].find(ann) != (size_t)-1) {
910
fileContents[i] = fileContents[i].substr(0, fileContents[i].find(ann));
1011
}
1112
}
1213
}
1314
void removeMultiAnn(std::vector<std::string> &fileContents, std::string ann) {
1415
size_t pos;
1516
size_t pos2;
16-
for (int i = 0; i < fileContents.size(); i++) {
17-
if ((pos=fileContents[i].find(ann)) != -1) {
18-
if ((pos2=fileContents[i].find(ann, pos + ann.length())) != -1) {
17+
for (size_t i = 0; i < fileContents.size(); i++) {
18+
if ((pos=fileContents[i].find(ann)) != (size_t)-1) {
19+
if ((pos2=fileContents[i].find(ann, pos + ann.length())) != (size_t)-1) {
1920
fileContents[i] = fileContents[i].substr(0, pos) + fileContents[i].substr(pos2 + ann.length());
2021
} else {
2122
fileContents[i] = fileContents[i].substr(0, pos);
2223
i++;
23-
while ((pos=fileContents[i].find(ann)) == -1) {
24+
while ((pos=fileContents[i].find(ann)) == (size_t)-1) {
2425
fileContents.erase(fileContents.begin() + i);
2526
i++;
2627
}
@@ -31,7 +32,7 @@ void removeMultiAnn(std::vector<std::string> &fileContents, std::string ann) {
3132
}
3233

3334
void removeEmptyLines(std::vector<std::string> &fileContents) {
34-
for (int i = 0; i < fileContents.size(); i++) {
35+
for (size_t i = 0; i < fileContents.size(); i++) {
3536
if (fileContents[i].empty()) {
3637
fileContents.erase(fileContents.begin() + i);
3738
i--;
@@ -40,15 +41,15 @@ void removeEmptyLines(std::vector<std::string> &fileContents) {
4041
}
4142

4243
void replaceWinNewLines(std::vector<std::string> &fileContents) {
43-
for (int i = 0; i < fileContents.size(); i++) {
44+
for (size_t i = 0; i < fileContents.size(); i++) {
4445
fileContents[i].erase(std::remove(fileContents[i].begin(), fileContents[i].end(), '\r'), fileContents[i].end());
4546
}
4647
}
4748

4849
void removeBlankLines(std::vector<std::string> &fileContents) {
4950
bool removeline = true;
50-
for (int i = 0; i < fileContents.size(); i++) {
51-
for (int j = 0; j < fileContents[i].length(); j++) if (fileContents[i][j] != ' ' && fileContents[i][j] != '\t') removeline = false;
51+
for (size_t i = 0; i < fileContents.size(); i++) {
52+
for (size_t j = 0; j < fileContents[i].length(); j++) if (fileContents[i][j] != ' ' && fileContents[i][j] != '\t') removeline = false;
5253
if (removeline) {
5354
fileContents.erase(fileContents.begin() + i);
5455
i--;
@@ -60,8 +61,8 @@ void removeBlankLines(std::vector<std::string> &fileContents) {
6061
std::pair<bool,bool> isSpaced(std::vector<std::string> &fileContents) {
6162
bool isSpaced = false;
6263
bool error = false;
63-
for (int i = 0; i < fileContents.size(); i++) {
64-
if (fileContents[i].find(":") != -1) {
64+
for (size_t i = 0; i < fileContents.size(); i++) {
65+
if (fileContents[i].find(":") != (size_t)-1) {
6566
if (fileContents[i+1][0] == ' ') isSpaced = true;
6667
else if (fileContents[i+1][0] != '\t') error = true;
6768
}

src/formatting/languages/python/formatter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ void pyFormat(std::vector<std::string> &fileContents) {
2525
std::vector<int> spacesVec;
2626
int indentation = 0;
2727
std::cout << "Detected spaced indentation" << std::endl;
28-
for (int i = 0; i < fileContents.size(); i++) {
28+
for (size_t i = 0; i < fileContents.size(); i++) {
2929
spaces = 0;
30-
for (int j = 0; j < fileContents[i].length(); j++) {
30+
for (size_t j = 0; j < fileContents[i].length(); j++) {
3131
if (fileContents[i][j] == ' ') while (fileContents[i][j] == ' ') {
3232
spaces++;
3333
j++;
@@ -36,7 +36,7 @@ void pyFormat(std::vector<std::string> &fileContents) {
3636
}
3737
spacesVec.push_back(spaces);
3838
}
39-
for (int i = 0; i < spacesVec.size(); i++) {
39+
for (size_t i = 0; i < spacesVec.size(); i++) {
4040
if (spacesVec[i] > 0) {
4141
for (int j = stoi(getValue("MAX_INDENT_SPACE")); j > 1; j--) {
4242
if (spacesVec[i] % j == 0) {
@@ -56,7 +56,7 @@ void pyFormat(std::vector<std::string> &fileContents) {
5656
std::cin >> indentation;
5757
}
5858
// check manually because i dont trust the user
59-
for (int i = 0; i < spacesVec.size(); i++) {
59+
for (size_t i = 0; i < spacesVec.size(); i++) {
6060
if (spacesVec[i] % indentation != 0) {
6161
std::cout << "Indentation error" << std::endl;
6262
return;

src/main.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
#include "headers/formatting.hpp"
66

77
int main(int argc, char* argv[]) {
8-
std::string file; int compact = 0; std::string output; std::string language;
9-
bool debug = false;
8+
std::string file; /*int compact = 0;*/ std::string output; std::string language; /*bool debug = false;*/
109
for (int i = 0; i < argc - 1; i++) {
1110
if (!std::strcmp(argv[i], "-f") && isFileReal(argv[i + 1])) file = argv[i + 1];
12-
if (!std::strcmp(argv[i], "-c")) compact = atoi(argv[i + 1]);
11+
// if (!std::strcmp(argv[i], "-c")) compact = atoi(argv[i + 1]);
1312
if (!std::strcmp(argv[i], "-o")) output = argv[i + 1];
1413
if (!std::strcmp(argv[i], "-l")) language = argv[i + 1];
15-
if (!std::strcmp(argv[i], "-d")) debug = 1;
14+
// if (!std::strcmp(argv[i], "-d")) debug = 1;
1615
if (!std::strcmp(argv[i], "-h")) {
1716
std::cout << "usage stuff..." << std::endl;
1817
return 0;

0 commit comments

Comments
 (0)