diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2018-01-14 06:16:36 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2018-01-14 06:16:36 +0000 |
commit | cf3c1bae51c0c688df7c54e717c64976df5ceb9f (patch) | |
tree | eeeaddf7d94b26009c39ba57f8c911f6589ecd9c /Build/source/texk/kpathsea | |
parent | 43190ae38d616e5d0cc8a32384ff959e9a4fc909 (diff) |
Kpathsea: Use a macro instead of a function strlen() to check if a string is empty or not. From Douglas McKenna,
git-svn-id: svn://tug.org/texlive/trunk@46307 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/kpathsea')
-rw-r--r-- | Build/source/texk/kpathsea/ChangeLog | 6 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/progname.c | 15 |
2 files changed, 14 insertions, 7 deletions
diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog index a57bcff5467..450df56ebf1 100644 --- a/Build/source/texk/kpathsea/ChangeLog +++ b/Build/source/texk/kpathsea/ChangeLog @@ -1,3 +1,9 @@ +2018-01-14 Akira Kakuto <kakuto@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@freefriends.org> * pathsearch.c (dir_list_search, dir_list_search_list): save the diff --git a/Build/source/texk/kpathsea/progname.c b/Build/source/texk/kpathsea/progname.c index fa4a7764334..984fceadd6c 100644 --- a/Build/source/texk/kpathsea/progname.c +++ b/Build/source/texk/kpathsea/progname.c @@ -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 @@ CopyFirst (register char *a, char *b) /* 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 @@ expand_symlinks (kpathsea kpse, char *s) 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 @@ expand_symlinks (kpathsea kpse, char *s) } 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 @@ expand_symlinks (kpathsea kpse, char *s) 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 @@ expand_symlinks (kpathsea kpse, char *s) 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); |