texlive[46459] Build/source/texk/kpathsea: STR_LIST_EMPTY,

commits+karl at tug.org commits+karl at tug.org
Sat Jan 27 17:58:57 CET 2018


Revision: 46459
          http://tug.org/svn/texlive?view=revision&revision=46459
Author:   karl
Date:     2018-01-27 17:58:57 +0100 (Sat, 27 Jan 2018)
Log Message:
-----------
STR_LIST_EMPTY, STR_LIST_FIRST_ELT convenience macros

Modified Paths:
--------------
    trunk/Build/source/texk/kpathsea/ChangeLog
    trunk/Build/source/texk/kpathsea/kpsewhich.c
    trunk/Build/source/texk/kpathsea/pathsearch.c
    trunk/Build/source/texk/kpathsea/str-list.c
    trunk/Build/source/texk/kpathsea/str-list.h

Modified: trunk/Build/source/texk/kpathsea/ChangeLog
===================================================================
--- trunk/Build/source/texk/kpathsea/ChangeLog	2018-01-27 13:05:43 UTC (rev 46458)
+++ trunk/Build/source/texk/kpathsea/ChangeLog	2018-01-27 16:58:57 UTC (rev 46459)
@@ -1,3 +1,10 @@
+2018-01-27  Karl Berry  <karl at 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 at freefriends.org>
 
 	* tex-file.c (kpathsea_init_format_return_varlist): log a newline

Modified: trunk/Build/source/texk/kpathsea/kpsewhich.c
===================================================================
--- trunk/Build/source/texk/kpathsea/kpsewhich.c	2018-01-27 13:05:43 UTC (rev 46458)
+++ trunk/Build/source/texk/kpathsea/kpsewhich.c	2018-01-27 16:58:57 UTC (rev 46459)
@@ -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 @@
   }
 
   /* 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 @@
 
   /* --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;
   }
 

Modified: trunk/Build/source/texk/kpathsea/pathsearch.c
===================================================================
--- trunk/Build/source/texk/kpathsea/pathsearch.c	2018-01-27 13:05:43 UTC (rev 46458)
+++ trunk/Build/source/texk/kpathsea/pathsearch.c	2018-01-27 16:58:57 UTC (rev 46459)
@@ -307,7 +307,7 @@
       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 @@
 
   /* 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 @@
       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 @@
   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);
 

Modified: trunk/Build/source/texk/kpathsea/str-list.c
===================================================================
--- trunk/Build/source/texk/kpathsea/str-list.c	2018-01-27 13:05:43 UTC (rev 46458)
+++ trunk/Build/source/texk/kpathsea/str-list.c	2018-01-27 16:58:57 UTC (rev 46459)
@@ -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 @@
 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) =

Modified: trunk/Build/source/texk/kpathsea/str-list.h
===================================================================
--- trunk/Build/source/texk/kpathsea/str-list.h	2018-01-27 13:05:43 UTC (rev 46458)
+++ trunk/Build/source/texk/kpathsea/str-list.h	2018-01-27 16:58:57 UTC (rev 46459)
@@ -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 @@
 } 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 */
 



More information about the tex-live-commits mailing list