|
30 | 30 | #include "fmt-merge-msg.h"
|
31 | 31 | #include "gpg-interface.h"
|
32 | 32 | #include "sequencer.h"
|
| 33 | +#include "string-list.h" |
33 | 34 |
|
34 | 35 | #define DEFAULT_TWOHEAD (1<<0)
|
35 | 36 | #define DEFAULT_OCTOPUS (1<<1)
|
@@ -712,42 +713,17 @@ static int count_unmerged_entries(void)
|
712 | 713 | return ret;
|
713 | 714 | }
|
714 | 715 |
|
715 |
| -static void split_merge_strategies(const char *string, struct strategy **list, |
716 |
| - int *nr, int *alloc) |
717 |
| -{ |
718 |
| - char *p, *q, *buf; |
719 |
| - |
720 |
| - if (!string) |
721 |
| - return; |
722 |
| - |
723 |
| - buf = xstrdup(string); |
724 |
| - q = buf; |
725 |
| - for (;;) { |
726 |
| - p = strchr(q, ' '); |
727 |
| - if (!p) { |
728 |
| - ALLOC_GROW(*list, *nr + 1, *alloc); |
729 |
| - (*list)[(*nr)++].name = xstrdup(q); |
730 |
| - free(buf); |
731 |
| - return; |
732 |
| - } else { |
733 |
| - *p = '\0'; |
734 |
| - ALLOC_GROW(*list, *nr + 1, *alloc); |
735 |
| - (*list)[(*nr)++].name = xstrdup(q); |
736 |
| - q = ++p; |
737 |
| - } |
738 |
| - } |
739 |
| -} |
740 |
| - |
741 | 716 | static void add_strategies(const char *string, unsigned attr)
|
742 | 717 | {
|
743 |
| - struct strategy *list = NULL; |
744 |
| - int list_alloc = 0, list_nr = 0, i; |
745 |
| - |
746 |
| - memset(&list, 0, sizeof(list)); |
747 |
| - split_merge_strategies(string, &list, &list_nr, &list_alloc); |
748 |
| - if (list) { |
749 |
| - for (i = 0; i < list_nr; i++) |
750 |
| - append_strategy(get_strategy(list[i].name)); |
| 718 | + int i; |
| 719 | + |
| 720 | + if (string) { |
| 721 | + struct string_list list = STRING_LIST_INIT_DUP; |
| 722 | + struct string_list_item *item; |
| 723 | + string_list_split(&list, string, ' ', -1); |
| 724 | + for_each_string_list_item(item, &list) |
| 725 | + append_strategy(get_strategy(item->string)); |
| 726 | + string_list_clear(&list, 0); |
751 | 727 | return;
|
752 | 728 | }
|
753 | 729 | for (i = 0; i < ARRAY_SIZE(all_strategy); i++)
|
|
0 commit comments