Skip to content

Commit de72792

Browse files
committed
Added Line numbers at warnings
1 parent d5cf96c commit de72792

File tree

10 files changed

+26
-13
lines changed

10 files changed

+26
-13
lines changed

Linux/.cache/0.png

16.6 KB
Loading

Linux/.cache/1.png

22.8 KB
Loading

Linux/.cache/src/main.d

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
main.o: src/main.cc src/lib/globals.hh src/lib/objects.hh \
2+
src/lib/fileParser.hh src/lib/imageGenerator.hh src/lib/pdfCreator.hh

Linux/.cache/src/main.o

617 KB
Binary file not shown.

Linux/bitPresent

482 KB
Binary file not shown.
123 KB
Binary file not shown.

Linux/build/bitPresent

482 KB
Binary file not shown.

Linux/build/dat/defaultFont.ttf

49.9 KB
Binary file not shown.

Windows/BitPresent.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "pdfCreator.h"
77

88
//Initialize all global variables
9-
std::string Global::_VERSIONSTRING = "BitPresent v1.1.0";
9+
std::string Global::_VERSIONSTRING = "BitPresent v1.1.1";
1010

1111
int Global::_WIDTH = 1920;
1212
int Global::_HEIGHT = 1080;

Windows/fileParser.h

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#include "objects.h"
99

10+
int nDotWarn = 0;
11+
1012
std::vector<std::string> tokenize(std::string path)
1113
{
1214
std::vector<std::string> tokens;
@@ -16,17 +18,18 @@ std::vector<std::string> tokenize(std::string path)
1618

1719
std::string line;
1820
std::string buffer;
21+
int cline = 0;
1922

2023
while (std::getline(file, line))
2124
{
22-
if (line == "") continue;
23-
25+
cline += 1;
2426
if (line[0] == '.')
2527
{
2628
int index = line.find(" ");
2729
if (index == std::string::npos)
2830
{
29-
printf("[WARNING]: Invalid '.background' statement. Ignoring\n");
31+
printf("[WARNING](Line %d): Invalid '.' command statement. Ignoring\n", cline);
32+
nDotWarn++;
3033
continue;
3134
}
3235
else
@@ -47,21 +50,28 @@ std::vector<std::string> tokenize(std::string path)
4750

4851
void parse(std::vector<std::string> tokens)
4952
{
53+
int cline = nDotWarn;
54+
5055
for (int i = 0; i < tokens.size(); i++)
5156
{
57+
cline += 1;
58+
59+
//Skip empty tokens
60+
if (tokens[i] == "") continue;
61+
5262
//Check for commands
5363
if (tokens[i] == ".background")
5464
{
5565
i += 1;
56-
if (tokens[i][0] == '<' || tokens[i][0] == '[' || tokens[i][0] == '-') printf("[WARNING]: Using instruction(\"%s\") as argument for '.background'\n", tokens[i].c_str());
66+
if (tokens[i][0] == '<' || tokens[i][0] == '[' || tokens[i][0] == '-') printf("[WARNING](Line %d): Using instruction(\"%s\") as argument for '.background'\n", cline, tokens[i].c_str());
5767
Global::_BACKGROUND = tokens[i];
5868
continue;
5969
}
6070

6171
if (tokens[i] == ".image")
6272
{
6373
i += 1;
64-
if (tokens[i][0] == '<' || tokens[i][0] == '[' || tokens[i][0] == '-') printf("[WARNING]: Using instruction(\"%s\") as argument for '.image'\n", tokens[i].c_str());
74+
if (tokens[i][0] == '<' || tokens[i][0] == '[' || tokens[i][0] == '-') printf("[WARNING](Line %d): Using instruction(\"%s\") as argument for '.image'\n", cline, tokens[i].c_str());
6575
if (Global::_CSLIDE < 0) printf("[WARNING]: '.image' used outside of a slide. Ignoring...\n");
6676
else Global::_PRESENT->slides[Global::_CSLIDE].image = tokens[i];
6777
continue;
@@ -70,11 +80,11 @@ void parse(std::vector<std::string> tokens)
7080
if (tokens[i] == ".font")
7181
{
7282
i += 1;
73-
if (tokens[i][0] == '<' || tokens[i][0] == '[' || tokens[i][0] == '-') printf("[WARNING]: Using instruction(\"%s\") as argument for '.image'\n", tokens[i].c_str());
83+
if (tokens[i][0] == '<' || tokens[i][0] == '[' || tokens[i][0] == '-') printf("[WARNING](Line %d): Using instruction(\"%s\") as argument for '.image'\n", cline, tokens[i].c_str());
7484
Global::_FONT = { {"title", TTF_OpenFont(tokens[i].c_str(), 68)}, {"subtitle", TTF_OpenFont(tokens[i].c_str(), 50)}, {"normal", TTF_OpenFont(tokens[i].c_str(), 34)} };
7585
if (Global::_FONT["title"] == NULL || Global::_FONT["subtitle"] == NULL || Global::_FONT["normal"] == NULL)
7686
{
77-
printf("[ERROR]: Error loading font. Reverting to default\n");
87+
printf("[ERROR](Line %d): Error loading font. Reverting to default\n", cline);
7888
Global::_FONT = Global::_DEFAULTFONT;
7989
}
8090
continue;
@@ -92,6 +102,7 @@ void parse(std::vector<std::string> tokens)
92102

93103
Global::_TEXTCOLOR = new SDL_Color{ r, g, b };
94104
}
105+
continue;
95106
}
96107

97108
//Check for other defining Tokens
@@ -118,15 +129,15 @@ void parse(std::vector<std::string> tokens)
118129

119130
if (tokens[i][0] == '-' && tokens[i][tokens[i].length() - 1] == '-')
120131
{
121-
if (Global::_CSLIDE < 0) printf("[WARNING]: Defined subtitle outside of a slide. Ignoring...\n");
132+
if (Global::_CSLIDE < 0) printf("[WARNING](Line %d): Defined subtitle outside of a slide. Ignoring...\n", cline);
122133
else Global::_PRESENT->slides[Global::_CSLIDE].subtitle = tokens[i].substr(1, tokens[i].length() - 2);
123134
continue;
124135
}
125136

126137
if (tokens[i][0] == '*')
127138
{
128-
if (Global::_CSLIDE < 0) printf("[WARNING]: Defined subpoint outside of a slide. Ignoring...\n");
129-
else if (Global::_CPOINT < 0) printf("[WARNING]: Defined subpoint outside of a point. Ignoring...\n");
139+
if (Global::_CSLIDE < 0) printf("[WARNING](Line %d): Defined subpoint outside of a slide. Ignoring...\n", cline);
140+
else if (Global::_CPOINT < 0) printf("[WARNING](Line %d): Defined subpoint outside of a point. Ignoring...\n", cline);
130141
else
131142
{
132143
int cutoff = 1;
@@ -137,12 +148,12 @@ void parse(std::vector<std::string> tokens)
137148
}
138149

139150
//Add non-special strings as points to slides
140-
if (Global::_CSLIDE < 0) printf("[WARNING]: Defined point outside of a slide. Ignoring...\n");
151+
if (Global::_CSLIDE < 0) printf("[WARNING](Line %d): Defined point outside of a slide. Ignoring...\n", cline);
141152
else
142153
{
143154
Global::_PRESENT->slides[Global::_CSLIDE].points.push_back(Point(tokens[i]));
144155
Global::_CPOINT = Global::_CPOINT + 1;
145156
}
146157
}
147158
printf("[OK]: Finished Parsing\n");
148-
}
159+
}

0 commit comments

Comments
 (0)