diff options
author | Karl Berry <karl@freefriends.org> | 2018-01-27 16:58:57 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-01-27 16:58:57 +0000 |
commit | 14a7e126d73445bb27eed49cf89c502f142950b8 (patch) | |
tree | 27df18407c5b0b16ec4543b4d94c1a7d1c0927fe /Build/source/texk | |
parent | ab347d35d8af61e0935b23cd59beeaba0255e07f (diff) |
STR_LIST_EMPTY, STR_LIST_FIRST_ELT convenience macros
git-svn-id: svn://tug.org/texlive/trunk@46459 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk')
-rw-r--r-- | Build/source/texk/kpathsea/ChangeLog | 7 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/kpsewhich.c | 6 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/pathsearch.c | 8 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/str-list.c | 6 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/str-list.h | 9 |
5 files changed, 23 insertions, 13 deletions
diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog index 2a9eca19ab4..f27718d087a 100644 --- a/Build/source/texk/kpathsea/ChangeLog +++ b/Build/source/texk/kpathsea/ChangeLog @@ -1,3 +1,10 @@ +2018-01-27 Karl Berry <karl@freefriends.org> + + * str-list.h (STR_LIST_EMPTY, STR_LIST_FIRST_ELT): new macros. + * kpsewhich.c, + * pathsearch.c, + * str-list.c (str_list_concat_elements): use them. + 2018-01-26 Karl Berry <karl@freefriends.org> * tex-file.c (kpathsea_init_format_return_varlist): log a newline diff --git a/Build/source/texk/kpathsea/kpsewhich.c b/Build/source/texk/kpathsea/kpsewhich.c index 4271bc1a3e7..41862d7ba9e 100644 --- a/Build/source/texk/kpathsea/kpsewhich.c +++ b/Build/source/texk/kpathsea/kpsewhich.c @@ -1,7 +1,7 @@ /* kpsewhich -- standalone path lookup and variable expansion for Kpathsea. Ideas from Thomas Esser, Pierre MacKay, and many others. - Copyright 1995-2017 Karl Berry & Olaf Weber. + Copyright 1995-2018 Karl Berry & Olaf Weber. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -425,7 +425,7 @@ lookup (kpathsea kpse, string name) } /* Filter by subdirectories, if specified. */ - if (STR_LIST_LENGTH (subdir_paths) > 0) { + if (!STR_LIST_EMPTY (subdir_paths)) { #if defined(WIN32) string *new_list = kpathsea_subdir_match (kpse, subdir_paths, ret_list); #else @@ -845,7 +845,7 @@ main (int argc, string *argv) /* --subdir must imply --all, since we filter here after doing the search, rather than inside the search itself. */ - if (STR_LIST_LENGTH (subdir_paths) > 0) { + if (!STR_LIST_EMPTY (subdir_paths)) { show_all = 1; } diff --git a/Build/source/texk/kpathsea/pathsearch.c b/Build/source/texk/kpathsea/pathsearch.c index 0aa7be58a9a..24dc472b536 100644 --- a/Build/source/texk/kpathsea/pathsearch.c +++ b/Build/source/texk/kpathsea/pathsearch.c @@ -307,7 +307,7 @@ path_search (kpathsea kpse, const_string path, string name, if (all) { str_list_concat (&ret_list, *found); } else { - str_list_add (&ret_list, STR_LIST_ELT (*found, 0)); + str_list_add (&ret_list, STR_LIST_FIRST_ELT (*found)); done = true; } } @@ -383,7 +383,7 @@ search (kpathsea kpse, const_string path, const_string original_name, /* Append NULL terminator if we didn't find anything at all, or we're supposed to find ALL and the list doesn't end in NULL now. */ - if (STR_LIST_LENGTH (ret_list) == 0 + if (STR_LIST_EMPTY (ret_list) || (all && STR_LIST_LAST_ELT (ret_list) != NULL)) str_list_add (&ret_list, NULL); @@ -514,7 +514,7 @@ kpathsea_path_search_list_generic (kpathsea kpse, if (all) { str_list_concat (&ret_list, *found); } else { - str_list_add (&ret_list, STR_LIST_ELT (*found, 0)); + str_list_add (&ret_list, STR_LIST_FIRST_ELT (*found)); done = true; } } @@ -526,7 +526,7 @@ kpathsea_path_search_list_generic (kpathsea kpse, str_list_uniqify (&ret_list); /* Add NULL if we will be returning multiple elements. */ - if (STR_LIST_LENGTH (ret_list) == 0 + if (STR_LIST_EMPTY (ret_list) || (all && STR_LIST_LAST_ELT (ret_list) != NULL)) str_list_add (&ret_list, NULL); diff --git a/Build/source/texk/kpathsea/str-list.c b/Build/source/texk/kpathsea/str-list.c index 750ccd916ad..e008874f5ca 100644 --- a/Build/source/texk/kpathsea/str-list.c +++ b/Build/source/texk/kpathsea/str-list.c @@ -1,6 +1,6 @@ /* str-list.c: define routines for string lists. - Copyright 1993, 2008, 2012 Karl Berry. + Copyright 1993, 2008, 2012, 2018 Karl Berry. Copyright 2001, 2005 Olaf Weber. This library is free software; you can redistribute it and/or @@ -65,9 +65,9 @@ str_list_concat (str_list_type *target, str_list_type more) void str_list_concat_elements (str_list_type *target, str_list_type more) { - if (STR_LIST_LENGTH(more) == 0) { + if (STR_LIST_EMPTY (more)) { return; - } else if (STR_LIST_LENGTH(*target) == 0) { + } else if (STR_LIST_EMPTY (*target)) { unsigned int i; STR_LIST_LENGTH(*target) = STR_LIST_LENGTH(more); STR_LIST(*target) = diff --git a/Build/source/texk/kpathsea/str-list.h b/Build/source/texk/kpathsea/str-list.h index 770abbdd3d0..0644f10aac2 100644 --- a/Build/source/texk/kpathsea/str-list.h +++ b/Build/source/texk/kpathsea/str-list.h @@ -1,6 +1,6 @@ /* str-list.h: declarations for string lists. - Copyright 1993, 1994, 2007, 2008, 2010, 2012 Karl Berry. + Copyright 1993, 1994, 2007, 2008, 2010, 2012, 2018 Karl Berry. Copyright 1999, 2005 Olaf Weber. This library is free software; you can redistribute it and/or @@ -42,9 +42,12 @@ typedef struct } cstr_list_type; #define STR_LIST_LENGTH(l) ((l).length) +#define STR_LIST_EMPTY(l) (STR_LIST_LENGTH (l) == 0) + #define STR_LIST(l) ((l).list) -#define STR_LIST_ELT(l, n) STR_LIST (l)[n] -#define STR_LIST_LAST_ELT(l) STR_LIST_ELT (l, STR_LIST_LENGTH (l) - 1) +#define STR_LIST_ELT(l, n) (STR_LIST (l)[n]) +#define STR_LIST_FIRST_ELT(l) STR_LIST_ELT ((l), 0) +#define STR_LIST_LAST_ELT(l) STR_LIST_ELT ((l), STR_LIST_LENGTH (l) - 1) #ifdef MAKE_KPSE_DLL /* libkpathsea internal only */ |