Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion octoprint_octolapse/data/lib/c/gcode_comment_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ void gcode_comment_processor::update_feature_from_section(position& pos) const
break;
case (section_type_support_section):
pos.feature_type_tag = feature_type_support_feature;
}
break;
case (section_type_no_section):
// Not reached, but to silence the warning
break;
}
}

void gcode_comment_processor::update(std::string& comment)
Expand Down
2 changes: 1 addition & 1 deletion octoprint_octolapse/data/lib/c/gcode_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ bool gcode_parser::try_parse_gcode(const char* gcode, parsed_command& command)
char cur_char = *p_gcode;
if (cur_char == '\0' || cur_char == ';')
break;
else if (cur_char > 32 || cur_char == ' ' && has_seen_character)
else if (cur_char > 32 || (cur_char == ' ' && has_seen_character))
{
if (cur_char >= 'a' && cur_char <= 'z')
command.gcode.push_back(cur_char - 32);
Expand Down
2 changes: 1 addition & 1 deletion octoprint_octolapse/data/lib/c/gcode_position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ void gcode_position::update(parsed_command& command, const long file_line_number
if (height_increment_ != 0)
{
const double increment_double = p_current_pos->height / height_increment_;
unsigned const int increment = utilities::round_up_to_int(increment_double);
const int increment = utilities::round_up_to_int(increment_double);
if (increment > p_current_pos->height_increment && increment > 1)
{
p_current_pos->height_increment = increment;
Expand Down
42 changes: 37 additions & 5 deletions octoprint_octolapse/data/lib/c/gcode_position_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,17 @@
// Sometimes used to test performance in release mode.
//#include "test.h"

int main(int argc, wchar_t* argv[])
#if UNICODE
int main(int argc, wchar_t *argv[])
#else
int main(int argc, char *argv[])
#endif
{
wchar_t* program = argv[0];
#if UNICODE
wchar_t *program = argv[0];
#else
char *program = argv[0];
#endif
if (program == NULL) {
fprintf(stderr, "Fatal error: cannot decode argv[0]\n");
exit(1);
Expand All @@ -59,13 +67,38 @@ int main(int argc, wchar_t* argv[])
PyConfig_InitPythonConfig(&config);

if (argc && argv) {
#if UNICODE
status = PyConfig_SetString(&config, &config.program_name, program);
#else
wchar_t wprogram[PATH_MAX];
if (mbstowcs(wprogram, program, PATH_MAX) == (size_t)-1) {
fprintf(stderr, "Fatal error: cannot convert argv[0] to wchar_t\n");
exit(1);
}
status = PyConfig_SetString(&config, &config.program_name, wprogram);
#endif
if (PyStatus_Exception(status)) {
PyConfig_Clear(&config);
return 1;
}

#if UNICODE
status = PyConfig_SetArgv(&config, argc, argv);
#else
wchar_t **wargv = (wchar_t **)malloc(argc * sizeof(wchar_t *));
if (!wargv) {
fprintf(stderr, "Fatal error: memory allocation failed\n");
exit(1);
}
for (int i = 0; i < argc; i++) {
size_t len = strlen(argv[i]) + 1;
wargv[i] = (wchar_t *)malloc(len * sizeof(wchar_t));
if (!wargv[i] || mbstowcs(wargv[i], argv[i], len) == (size_t)-1) {
fprintf(stderr, "Fatal error: cannot convert argv[%d] to wchar_t\n", i);
exit(1);
}
}
status = PyConfig_SetArgv(&config, argc, wargv);
#endif
if (PyStatus_Exception(status)) {
PyConfig_Clear(&config);
return 1;
Expand Down Expand Up @@ -365,8 +398,7 @@ extern "C" {
}

// see if we already have a gcode_position object for the given key
std::map<std::string, gcode_position*>::iterator gcode_position_iterator = gpp::gcode_positions.find(pKey);
gcode_position* p_gcode_position = NULL;
std::map<std::string, gcode_position *>::iterator gcode_position_iterator = gpp::gcode_positions.find(pKey);
if (gcode_position_iterator != gpp::gcode_positions.end())
{
octolapse_log(octolapse_log::GCODE_POSITION, octolapse_log::INFO, "Existing processor found, deleting.");
Expand Down