diff options
author | Karl Berry <karl@freefriends.org> | 2018-01-27 17:04:25 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-01-27 17:04:25 +0000 |
commit | 6949dcd66c43979a6167ec26e7d92f6a0e4ffcd3 (patch) | |
tree | bf8bd48c399d6400810019562490c159ea883197 /Build/source/texk/kpathsea | |
parent | 14a7e126d73445bb27eed49cf89c502f142950b8 (diff) |
consistent code formatting
git-svn-id: svn://tug.org/texlive/trunk@46460 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/kpathsea')
-rw-r--r-- | Build/source/texk/kpathsea/ChangeLog | 2 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/str-list.c | 83 |
2 files changed, 45 insertions, 40 deletions
diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog index f27718d087a..de5e1a3be90 100644 --- a/Build/source/texk/kpathsea/ChangeLog +++ b/Build/source/texk/kpathsea/ChangeLog @@ -1,5 +1,7 @@ 2018-01-27 Karl Berry <karl@freefriends.org> + * str-list.c (str_list_concat_elements): reformat for consistency. + * str-list.h (STR_LIST_EMPTY, STR_LIST_FIRST_ELT): new macros. * kpsewhich.c, * pathsearch.c, diff --git a/Build/source/texk/kpathsea/str-list.c b/Build/source/texk/kpathsea/str-list.c index e008874f5ca..676aaa0ad26 100644 --- a/Build/source/texk/kpathsea/str-list.c +++ b/Build/source/texk/kpathsea/str-list.c @@ -53,50 +53,54 @@ str_list_concat (str_list_type *target, str_list_type more) STR_LIST_LENGTH (*target) += STR_LIST_LENGTH (more); XRETALLOC (STR_LIST (*target), STR_LIST_LENGTH (*target), string); - for (e = 0; e < STR_LIST_LENGTH (more); e++) + for (e = 0; e < STR_LIST_LENGTH (more); e++) { STR_LIST_ELT (*target, prev_len + e) = STR_LIST_ELT (more, e); + } } -/* Concatenate the elements of more to each element of target. This - _must_ be done with the first index varying fastest. */ -/* Note that we free the old elements of target as well. */ +/* Concatenate the elements of MORE to each element of TARGET. This + _must_ be done with the first index varying fastest. + We free the old elements of TARGET. */ void str_list_concat_elements (str_list_type *target, str_list_type more) { - if (STR_LIST_EMPTY (more)) { - return; - } else if (STR_LIST_EMPTY (*target)) { - unsigned int i; - STR_LIST_LENGTH(*target) = STR_LIST_LENGTH(more); - STR_LIST(*target) = - (string*)xmalloc(STR_LIST_LENGTH(more)*sizeof(char*)); - for (i=0;i!=STR_LIST_LENGTH(more);++i) { - STR_LIST_ELT(*target,i)=xstrdup(STR_LIST_ELT(more,i)); - } - return; - } else { - unsigned new_len; - char ** new_list; - unsigned int i,j; - new_list = (string*)xmalloc(STR_LIST_LENGTH (*target) - * STR_LIST_LENGTH (more) * sizeof(char*)); - - new_len = 0; - for (j = 0; j != STR_LIST_LENGTH(more); ++j) { - for (i = 0; i != STR_LIST_LENGTH(*target); ++i) { - new_list[new_len] = concat(STR_LIST_ELT(*target,i), - STR_LIST_ELT(more,j)); - ++new_len; - } - } - for (i = 0; i != STR_LIST_LENGTH(*target); ++i) - free(STR_LIST_ELT(*target, i)); - free(STR_LIST(*target)); - STR_LIST_LENGTH(*target) = new_len; - STR_LIST(*target) = new_list; + if (STR_LIST_EMPTY (more)) { + return; + + } else if (STR_LIST_EMPTY (*target)) { + unsigned i; + STR_LIST_LENGTH (*target) = STR_LIST_LENGTH (more); + STR_LIST (*target) = (string *) xmalloc (STR_LIST_LENGTH (more) + * sizeof (char *)); + for (i = 0; i != STR_LIST_LENGTH (more); ++i) { + STR_LIST_ELT (*target, i) = xstrdup (STR_LIST_ELT (more, i)); + } + return; + + } else { + unsigned new_len; + char **new_list; + unsigned i, j; + new_list = (string *) xmalloc (STR_LIST_LENGTH (*target) + * STR_LIST_LENGTH (more) + * sizeof (char *)); + new_len = 0; + for (j = 0; j != STR_LIST_LENGTH (more); ++j) { + for (i = 0; i != STR_LIST_LENGTH (*target); ++i) { + new_list[new_len] = concat (STR_LIST_ELT (*target, i), + STR_LIST_ELT (more, j)); + ++new_len; + } } + for (i = 0; i != STR_LIST_LENGTH(*target); ++i) { + free (STR_LIST_ELT (*target, i)); + } + free (STR_LIST (*target)); + STR_LIST_LENGTH (*target) = new_len; + STR_LIST (*target) = new_list; + } } @@ -105,11 +109,10 @@ str_list_concat_elements (str_list_type *target, str_list_type more) void str_list_free (str_list_type *l) { - if (STR_LIST (*l)) - { - free (STR_LIST (*l)); - STR_LIST (*l) = NULL; - } + if (STR_LIST (*l)) { + free (STR_LIST (*l)); + STR_LIST (*l) = NULL; + } } |