Skip to content

Commit

Permalink
Update: Shell.c, Globals.h: Improvement of arg parsing to support com…
Browse files Browse the repository at this point in the history
…pound term arguments for motorbabbling
  • Loading branch information
patham9 committed Jul 12, 2022
1 parent 965cb3d commit 296e614
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,8 @@ HASH_TYPE Globals_Hash(HASH_TYPE *data, int pieces);
int myrand(void);
void mysrand(unsigned int seed);
#define MY_RAND_MAX 32767
//Stringification macro:
#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)

#endif
2 changes: 1 addition & 1 deletion src/Shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ int Shell_ProcessInput(char *line)
int opID;
int opArgID;
char argname[ATOMIC_TERM_LEN_MAX] = {0};
sscanf(&line[strlen("*setoparg ")], "%d %d %s", &opID, &opArgID, (char*) &argname);
sscanf(&line[strlen("*setoparg ")], "%d %d %" STR(ATOMIC_TERM_LEN_MAX) "[^\n]", &opID, &opArgID, (char*) &argname);
assert(opID >= 1 && opID <= OPERATIONS_MAX, "Operator index out of bounds, it can only be between 1 and OPERATIONS_MAX!");
assert(opArgID >= 1 && opArgID <= OPERATIONS_BABBLE_ARGS_MAX, "Operator arg index out of bounds, it can only be between 1 and OPERATIONS_BABBLE_ARGS_MAX!");
operations[opID - 1].arguments[opArgID-1] = Narsese_Term(argname);
Expand Down

0 comments on commit 296e614

Please sign in to comment.