Skip to content

Commit 2b2bd78

Browse files
Reenable settings file parsing and uncomment strtok_r usage, but use strtok_s in Windows
1 parent dd9d920 commit 2b2bd78

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

KeyboardVisualizerQT/main.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
#include "KeyboardVisualizerCommon/Visualizer.h"
44
#include "KeyboardVisualizerCommon/VisualizerDefines.h"
55

6+
#if defined(_WIN32) || defined(_WIN64)
7+
/* We are on Windows */
8+
# define strtok_r strtok_s
9+
#endif
10+
611
#ifndef WIN32
712
#include <unistd.h>
813
#endif
@@ -159,7 +164,7 @@ bool parse_command_line(int argc, char *argv[])
159164
char* argument;
160165
char* value;
161166

162-
//argument = strtok_r(argv[i], "=", &value);
167+
argument = strtok_r(argv[i], "=", &value);
163168

164169
if (strcmp(argument, "help") == 0)
165170
{
@@ -260,7 +265,7 @@ void parse_settings_file(char * filename)
260265

261266
value = (char *)line.c_str();
262267

263-
//argument = strtok_r(value, "=", &value);
268+
argument = strtok_r(value, "=", &value);
264269

265270
parse_argument_string(argument, value);
266271
}
@@ -277,16 +282,8 @@ int main(int argc, char *argv[])
277282
//Initialize Visualizer
278283
vis.Initialize();
279284

280-
//Get file path in executable directory
281-
//char filename[2048];
282-
//GetModuleFileName(NULL, filename, 2048);
283-
//char arg1[64];
284-
//snprintf(arg1, 64, "/proc/%d/exe", getpid());
285-
//readlink(arg1, filename, 1024);
286-
//strcpy(filename, std::string(filename).substr(0, std::string(filename).find_last_of("\\/")).c_str());
287-
//strcat(filename, "\\settings.txt");
288-
//strcat(filename, "/settings.txt");
289-
//parse_settings_file(filename);
285+
//Parse Settings File
286+
parse_settings_file("settings.txt");
290287

291288
//Parse Command Line
292289
if (!parse_command_line(argc, argv))

0 commit comments

Comments
 (0)