Skip to content

Commit 9599212

Browse files
committed
fixed null parameters a lil bit
1 parent 9a9a4fa commit 9599212

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

linked-list.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ void print_linked_list_string(linked_list_string* my_linked_list){
4949
printf("this is a help about this program showed if arg is -h or --help\n");
5050
for(i=0;i<(my_linked_list->len);i++){
5151
if(tmp->type == INT)
52-
printf("\t %s : --%s [integer] or -%s [integer]\n",tmp->detail,tmp->self,tmp->short_self);
53-
if(tmp->type == CHAR)
54-
printf("\t %s : --%s [string] or -%s [string]\n",tmp->detail,tmp->self,tmp->short_self);
55-
if(tmp->type == BOOL)
56-
printf("\t %s : --%s or -%s\n",tmp->detail,tmp->self,tmp->short_self);
52+
printf("\t--> %s : --%s [integer] or -%s [integer]\n",tmp->detail,tmp->self,tmp->short_self);
53+
else if(tmp->type == CHAR)
54+
printf("\t--> %s : --%s [string] or -%s [string]\n",tmp->detail,tmp->self,tmp->short_self);
55+
else if(tmp->type == BOOL)
56+
printf("\t--> %s : --%s or -%s\n",tmp->detail,tmp->self,tmp->short_self);
5757
//printf("%s | ",tmp->self);
5858
tmp = tmp->next;
5959
}
60-
printf("\n");
60+
//printf("\n");
6161

6262
}
6363
void init_node(node_string* mynode){
@@ -97,6 +97,13 @@ int create_node_with_help_and_action(node_string* tmp,char* self,char* short_sel
9797
tmp->detail = malloc(SIZE_DETAIL*sizeof(char));
9898
//tmp->action = action;
9999
tmp->type = type;
100+
tmp->status = False;
101+
tmp->required = required;
102+
str_cp(tmp->short_self,short_self);
103+
str_cp(tmp->self,self);
104+
str_cp(tmp->detail,detail);
105+
tmp->data_fullness = 4;
106+
tmp->index = 0;
100107
if(type == INT){
101108
if(action_int)
102109
tmp->action_int = action_int;
@@ -117,23 +124,18 @@ int create_node_with_help_and_action(node_string* tmp,char* self,char* short_sel
117124
}
118125
else
119126
return 0;
120-
tmp->status = False;
121-
tmp->required = required;
122-
str_cp(tmp->short_self,short_self);
123-
str_cp(tmp->self,self);
124-
str_cp(tmp->detail,detail);
125-
tmp->data_fullness = 4;
126-
tmp->index = 0;
127127
return 1;
128128
}
129129
node_string* get_node_by_self(char* self,linked_list_string* mylist){
130130
node_string* tmp = mylist->head;
131-
while(tmp->next != mylist->head){
131+
int i = 0;
132+
while(i<(mylist->len)){
132133
if((str_cmp(tmp->self,self) == 1) || (str_cmp(tmp->short_self,self) == 1)){
133134
//printf("i have found it\n");
134135
return tmp;
135136
}
136137
tmp = tmp->next;
138+
i++;
137139
}
138140
return NULL;
139141
}

0 commit comments

Comments
 (0)