Skip to content
Snippets Groups Projects
Commit a1f99c09 authored by Andrew To's avatar Andrew To
Browse files

Fix small bugs which didn't appear in tux but in local machine

parent 51daf0de
No related branches found
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
......@@ -32,14 +32,6 @@
* Standard Library Functions You Might Want To Consider Using
* memset(), strcmp(), strcpy(), strtok(), strlen(), strchr()
*/
int build_cmd_list(char *cmd_line, command_list_t *clist)
{
char *pointer = cmd_line;
char* pipe = strchr(pointer, PIPE_CHAR);
clist->num = 0;
command_t new_command;
void make_command(command_t new_command, char *pointer, command_list_t *clist, size_t sub_length){
while (*pointer == ' '){
......@@ -55,7 +47,10 @@ int build_cmd_list(char *cmd_line, command_list_t *clist)
memset(new_command.args, 0, sizeof(new_command.args));
new_command.args[0] = '\0';
if (clist->num < CMD_MAX){
clist->commands[clist->num] = new_command;
}
clist->num = clist->num+1;
} else{
while (*space==' '){
......@@ -70,12 +65,23 @@ int build_cmd_list(char *cmd_line, command_list_t *clist)
memset(new_command.args, 0, sizeof(new_command.args));
strncpy(new_command.args, space, arg_length);
new_command.args[arg_length] = '\0';
if (clist->num < CMD_MAX){
clist->commands[clist->num] = new_command;
}
clist->num = clist->num+1;
}
}
int build_cmd_list(char *cmd_line, command_list_t *clist)
{
char *pointer = cmd_line;
char* pipe = strchr(pointer, PIPE_CHAR);
clist->num = 0;
while(pointer != NULL){
command_t new_command;
pipe = strchr(pointer, PIPE_CHAR);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment