Skip to content

Commit

Permalink
fixed cc option bug
Browse files Browse the repository at this point in the history
  • Loading branch information
chuckliu1979 committed Mar 17, 2016
1 parent 35658f0 commit eb0604e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
26 changes: 24 additions & 2 deletions src/bugz_modify.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,32 @@ int bugz_modify_main(int argc, char **argv) {
_append_modify_arg_(remove_dependson);
break;
case opt_modify_add_cc :
_append_modify_arg_(add_cc);
if (1) {
char *token, *str;
str = (char *)malloc(strlen(optarg)+1);
strcpy(str, optarg);
token = strtok(str, ",");
while (token != NULL) {
bugz_modify_arguments.add_cc = \
curl_slist_append(bugz_modify_arguments.add_cc, token);
token = strtok(NULL, ",");
}
free(str);
}
break;
case opt_modify_remove_cc :
_append_modify_arg_(remove_cc);
if (1) {
char *token, *str;
str = (char *)malloc(strlen(optarg)+1);
strcpy(str, optarg);
token = strtok(str, ",");
while (token != NULL) {
bugz_modify_arguments.remove_cc = \
curl_slist_append(bugz_modify_arguments.remove_cc, token);
token = strtok(NULL, ",");
}
free(str);
}
break;
case opt_modify_component :
_append_modify_arg_(component);
Expand Down
13 changes: 5 additions & 8 deletions src/bugz_post.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,18 +597,15 @@ int bugz_post_main(int argc, char **argv) {
fprintf(stdout, "%-12s: %s\n", "Assigned to", json_object_get_string(val));
}
if (bugz_post_arguments.cc) {
char *q, *p, buf[1024] = { 0 };
char *q, *p;
struct curl_slist *last = bugz_slist_get_last(bugz_post_arguments.cc);
val = json_object_new_array();
p = last->data;
while ((q = strchr(p, ',')) != NULL){
memcpy(buf, p, q - p);
buf[q-p+1] = 0;
json_object_array_add(val, json_object_new_string(buf));
p = q + 1;
q = strtok(p, ",");
while (q != NULL){
json_object_array_add(val, json_object_new_string(q));
q = strtok(NULL, ",");
}
if (strlen(p))
json_object_array_add(val, json_object_new_string(p));
json_object_object_add(json, "cc", val);
fprintf(stdout, "%-12s: %s\n", "CC", json_object_get_string(val));
}
Expand Down

0 comments on commit eb0604e

Please sign in to comment.