texlive[46307] Build/source/texk/kpathsea: Kpathsea: Use a macro

commits+kakuto at tug.org commits+kakuto at tug.org
Sun Jan 14 07:16:37 CET 2018


Revision: 46307
          http://tug.org/svn/texlive?view=revision&revision=46307
Author:   kakuto
Date:     2018-01-14 07:16:36 +0100 (Sun, 14 Jan 2018)
Log Message:
-----------
Kpathsea: Use a macro instead of a function strlen() to check if a string is empty or not. From Douglas McKenna,

Modified Paths:
--------------
    trunk/Build/source/texk/kpathsea/ChangeLog
    trunk/Build/source/texk/kpathsea/progname.c

Modified: trunk/Build/source/texk/kpathsea/ChangeLog
===================================================================
--- trunk/Build/source/texk/kpathsea/ChangeLog	2018-01-14 01:23:27 UTC (rev 46306)
+++ trunk/Build/source/texk/kpathsea/ChangeLog	2018-01-14 06:16:36 UTC (rev 46307)
@@ -1,3 +1,9 @@
+2018-01-14  Akira Kakuto  <kakuto at fuk.kindai.ac.jp>
+
+	* progname.c: Use a macro instead of a function strlen() to
+	check if a string is empty or not. Report from Douglas McKenna,
+	private mail 14 Jan 2018.
+
 2018-01-05  Karl Berry  <karl at freefriends.org>
 
 	* pathsearch.c (dir_list_search, dir_list_search_list): save the

Modified: trunk/Build/source/texk/kpathsea/progname.c
===================================================================
--- trunk/Build/source/texk/kpathsea/progname.c	2018-01-14 01:23:27 UTC (rev 46306)
+++ trunk/Build/source/texk/kpathsea/progname.c	2018-01-14 06:16:36 UTC (rev 46307)
@@ -1,6 +1,6 @@
 /* progname.c: the executable name we were invoked as; general initialization.
 
-   Copyright 1994, 1996, 1997, 2008-2013, 2016 Karl Berry.
+   Copyright 1994, 1996, 1997, 2008-2013, 2016-2018 Karl Berry.
    Copyright 1998-2005 Olaf Weber.
 
    This library is free software; you can redistribute it and/or
@@ -156,7 +156,8 @@
 /* Returns NULL on error.  Prints intermediate results if global
    `ll_verbose' is nonzero.  */
 
-#define EX(s)           (strlen (s) && strcmp (s, "/") ? "/" : "")
+#define EMPTY_STRING(s) (*(s) == 0)
+#define EX(s)           (!EMPTY_STRING (s) && strcmp (s, "/") ? "/" : "")
 #define EXPOS           EX(post)
 #define EXPRE           EX(pre)
 
@@ -189,7 +190,7 @@
   strcpy (post, s);
   strcpy (pre, "");
 
-  while (strlen (post) != 0) {
+  while (!EMPTY_STRING (post)) {
     CopyFirst (pre, post);
 
     if (lstat (pre, &st) != 0) {
@@ -209,7 +210,7 @@
       } else {
         a = pre[0];     /* handle links through the root */
         strcpy (tmp, StripLast (pre));
-        if (!strlen (pre) && a == '/')
+        if (EMPTY_STRING (pre) && a == '/')
           strcpy (pre, "/");
 
         if (kpse->ll_verbose) {
@@ -223,7 +224,7 @@
         a = pre[0];     /* handle links through the root */
         while (!strncmp (sym, "..", 2)
                && (sym[2] == 0 || sym[2] == '/')
-               && strlen (pre) != 0
+               && !EMPTY_STRING (pre)
                && strcmp (pre, ".")
                && strcmp (pre, "..")
                && (strlen (pre) < 3
@@ -241,11 +242,11 @@
           else
             printf ("%s == %s%s%s\n", before, pre, EXPOS, post);
         }
-        if (!strlen (pre) && a == '/')
+        if (EMPTY_STRING (pre) && a == '/')
           strcpy (pre, "/");
       }
 
-      if (strlen (post) != 0 && strlen (sym) != 0)
+      if (!EMPTY_STRING (post) && !EMPTY_STRING (sym))
         strcat (sym, "/");
 
       strcat (sym, post);



More information about the tex-live-commits mailing list