Skip to content

Commit 9d17d10

Browse files
committed
strncmp fix
strncmpfunction was not working properly so it has been changed to simple strcmp.
1 parent d9292ec commit 9d17d10

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

Arduino/Advanced/interpreter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ void execute( char *cmd, int(*resp_fn)(const char*, ...) ){
505505
prev = &API_tree[0];
506506

507507
// Compare the first element in the tree with the command.
508-
comp_res = strncmp( (char*)*(prev->name), cmd, strlen( (char*)*(prev->name) ) );
508+
comp_res = strcmp( (char*)*(prev->name), cmd );
509509

510510
// Decide where to find the next element in the tree.
511511
(comp_res > 0) ? (next = (prev->left)) : ( next = (prev->right));
@@ -520,7 +520,7 @@ void execute( char *cmd, int(*resp_fn)(const char*, ...) ){
520520
prev = next;
521521

522522
// Compare the actual element in the tree with the command.
523-
comp_res = strncmp( (char*)*(prev->name), cmd, strlen( (char*)*(prev->name) ) );
523+
comp_res = strcmp( (char*)*(prev->name), cmd );
524524

525525
// Decide where to find the next element in the tree.
526526
// This step will overwrite the next variable and we will lost our address.

Arduino/Moderate/interpreter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ void execute( char *cmd, int(*resp_fn)(const char*, ...) ){
505505
prev = &API_tree[0];
506506

507507
// Compare the first element in the tree with the command.
508-
comp_res = strncmp( (char*)*(prev->name), cmd, strlen( (char*)*(prev->name) ) );
508+
comp_res = strcmp( (char*)*(prev->name), cmd );
509509

510510
// Decide where to find the next element in the tree.
511511
(comp_res > 0) ? (next = (prev->left)) : ( next = (prev->right));
@@ -520,7 +520,7 @@ void execute( char *cmd, int(*resp_fn)(const char*, ...) ){
520520
prev = next;
521521

522522
// Compare the actual element in the tree with the command.
523-
comp_res = strncmp( (char*)*(prev->name), cmd, strlen( (char*)*(prev->name) ) );
523+
comp_res = strcmp( (char*)*(prev->name), cmd );
524524

525525
// Decide where to find the next element in the tree.
526526
// This step will overwrite the next variable and we will lost our address.

Arduino/Simple/interpreter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ void execute( char *cmd, int(*resp_fn)(const char*, ...) ){
505505
prev = &API_tree[0];
506506

507507
// Compare the first element in the tree with the command.
508-
comp_res = strncmp( (char*)*(prev->name), cmd, strlen( (char*)*(prev->name) ) );
508+
comp_res = strcmp( (char*)*(prev->name), cmd );
509509

510510
// Decide where to find the next element in the tree.
511511
(comp_res > 0) ? (next = (prev->left)) : ( next = (prev->right));
@@ -520,7 +520,7 @@ void execute( char *cmd, int(*resp_fn)(const char*, ...) ){
520520
prev = next;
521521

522522
// Compare the actual element in the tree with the command.
523-
comp_res = strncmp( (char*)*(prev->name), cmd, strlen( (char*)*(prev->name) ) );
523+
comp_res = strcmp( (char*)*(prev->name), cmd );
524524

525525
// Decide where to find the next element in the tree.
526526
// This step will overwrite the next variable and we will lost our address.

src/interpreter.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ void execute( char *cmd, int(*resp_fn)(const char*, ...) ){
505505
prev = &API_tree[0];
506506

507507
// Compare the first element in the tree with the command.
508-
comp_res = strncmp( (char*)*(prev->name), cmd, strlen( (char*)*(prev->name) ) );
508+
comp_res = strcmp( (char*)*(prev->name), cmd );
509509

510510
// Decide where to find the next element in the tree.
511511
(comp_res > 0) ? (next = (prev->left)) : ( next = (prev->right));
@@ -520,7 +520,7 @@ void execute( char *cmd, int(*resp_fn)(const char*, ...) ){
520520
prev = next;
521521

522522
// Compare the actual element in the tree with the command.
523-
comp_res = strncmp( (char*)*(prev->name), cmd, strlen( (char*)*(prev->name) ) );
523+
comp_res = strcmp( (char*)*(prev->name), cmd );
524524

525525
// Decide where to find the next element in the tree.
526526
// This step will overwrite the next variable and we will lost our address.

0 commit comments

Comments
 (0)