diff options
author | Karl Berry <karl@freefriends.org> | 2018-01-28 00:16:43 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-01-28 00:16:43 +0000 |
commit | a1311caf9bd414269dca9ef7ddc2b9d2d810b280 (patch) | |
tree | 0db9b1988fddad1af3d0f22e2ee22d5472bae530 /Build | |
parent | 580074dc9e37bdf64a64e2a91d960c0017dd8023 (diff) |
doc fixes, code formatting
git-svn-id: svn://tug.org/texlive/trunk@46468 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r-- | Build/source/texk/kpathsea/ChangeLog | 4 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/readable.c | 113 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/readable.h | 10 |
3 files changed, 67 insertions, 60 deletions
diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog index de5e1a3be90..52b4e79b673 100644 --- a/Build/source/texk/kpathsea/ChangeLog +++ b/Build/source/texk/kpathsea/ChangeLog @@ -1,5 +1,9 @@ 2018-01-27 Karl Berry <karl@freefriends.org> + * readable.h: doc fixes. + * readable.c (READABLE): take (ignored) kpse arg in macro, so: + (kpathsea_readable_file): we can avoid #ifdefs in body. + * str-list.c (str_list_concat_elements): reformat for consistency. * str-list.h (STR_LIST_EMPTY, STR_LIST_FIRST_ELT): new macros. diff --git a/Build/source/texk/kpathsea/readable.c b/Build/source/texk/kpathsea/readable.c index afbd01d74dd..2623fd2b84f 100644 --- a/Build/source/texk/kpathsea/readable.c +++ b/Build/source/texk/kpathsea/readable.c @@ -43,28 +43,28 @@ READABLE(kpathsea kpse, const_string fn, unsigned int st) wchar_t *fnw; fnw = get_wstring_from_mbstring(kpse->File_system_codepage, fn, fnw=NULL); if ((st = GetFileAttributesW(fnw)) != 0xFFFFFFFF) { - /* succeeded */ - errno = 0; + /* succeeded */ + errno = 0; } else { - switch(GetLastError()) { - case ERROR_BUFFER_OVERFLOW: - errno = ENAMETOOLONG; - break; - case ERROR_ACCESS_DENIED: - errno = EACCES; - break; - default : - errno = EIO; /* meaningless, will make ret=NULL later */ - break; - } + switch(GetLastError()) { + case ERROR_BUFFER_OVERFLOW: + errno = ENAMETOOLONG; + break; + case ERROR_ACCESS_DENIED: + errno = EACCES; + break; + default : + errno = EIO; /* meaningless, will make ret=NULL later */ + break; + } } - if(fnw) free(fnw); - return ((st != 0xFFFFFFFF) && - !(st & FILE_ATTRIBUTE_DIRECTORY)); + if (fnw) + free (fnw); + return ((st != 0xFFFFFFFF) && !(st & FILE_ATTRIBUTE_DIRECTORY)); } -#else +#else /* not __DJGPP__ and not WIN32 */ #define READABLE(kpse, fn, st) \ - (access ((fn), R_OK) == 0 && stat (fn, &(st)) == 0 && !S_ISDIR ((st).st_mode)) + (access((fn), R_OK) == 0 && stat((fn), &(st)) == 0 && !S_ISDIR ((st).st_mode)) #endif @@ -83,52 +83,55 @@ kpathsea_readable_file (kpathsea kpse, string name) kpathsea_normalize_path (kpse, name); if (READABLE (kpse, name, st)) { - return name; + return name; #ifdef ENAMETOOLONG } else if (errno == ENAMETOOLONG) { - /* Truncate any too-long components in NAME. */ - unsigned c_len = 0; /* Length of current component. */ - char *s = name; /* Position in current component. */ - char *t = name; /* End of allowed length. */ - - for (; *s; s++) { - if (c_len <= NAME_MAX) - t = s; + /* Truncate any too-long components in NAME. */ + unsigned c_len = 0; /* Length of current component. */ + char *s = name; /* Position in current component. */ + char *t = name; /* End of allowed length. */ + + for (; *s; s++) { + if (c_len <= NAME_MAX) { + t = s; + } #if defined(WIN32) - if (kpathsea_IS_KANJI (kpse, s)) { - s++; - c_len += 2; - continue; - } + if (kpathsea_IS_KANJI (kpse, s)) { + s++; + c_len += 2; + continue; + } #endif /* WIN32 */ - if (IS_DIR_SEP (*s) || IS_DEVICE_SEP (*s)) { - if (c_len > NAME_MAX) { - /* Truncate if past the max for a component. */ - memmove (t, s, strlen (s) + 1); - s = t; - } - /* At a directory delimiter, reset component length. */ - c_len = 0; - } else - c_len++; + if (IS_DIR_SEP (*s) || IS_DEVICE_SEP (*s)) { + if (c_len > NAME_MAX) { + /* Truncate if past the max for a component. */ + memmove (t, s, strlen (s) + 1); + s = t; + } + /* At a directory delimiter, reset component length. */ + c_len = 0; + } else { + c_len++; } - if (c_len > NAME_MAX) - /* Truncate if past the max for last component. */ - *t = 0; - - /* Perhaps some other error will occur with the truncated name, so - let's call access again. */ - if (READABLE (kpse, name, st)) /* Success. */ - return name; + } + if (c_len > NAME_MAX) { + /* Truncate if past the max for last component. */ + *t = 0; + } + + /* Perhaps some other error will occur with the truncated name, so + let's call access again. */ + if (READABLE (kpse, name, st)) /* Success. */ + return name; #endif /* ENAMETOOLONG */ } else { /* Some other error. */ - if (errno == EACCES) { /* Maybe warn them if permissions are bad. */ - if (!kpathsea_tex_hush (kpse, "readable")) { - perror (name); - } + if (errno == EACCES) { /* Maybe warn them if permissions are bad. */ + if (!kpathsea_tex_hush (kpse, "readable")) { + perror (name); } + } } return NULL; @@ -139,6 +142,6 @@ kpathsea_readable_file (kpathsea kpse, string name) string kpse_readable_file (string name) { - return kpathsea_readable_file (kpse_def, name); + return kpathsea_readable_file (kpse_def, name); } #endif diff --git a/Build/source/texk/kpathsea/readable.h b/Build/source/texk/kpathsea/readable.h index 123e299b132..98e434bbcc2 100644 --- a/Build/source/texk/kpathsea/readable.h +++ b/Build/source/texk/kpathsea/readable.h @@ -1,6 +1,6 @@ /* readable.h: is a file readable? - Copyright 1993, 2008, 2009 Karl Berry. + Copyright 1993, 2008, 2009, 2018 Karl Berry. Copyright 1999, 2005 Olaf Weber. This library is free software; you can redistribute it and/or @@ -26,10 +26,10 @@ extern "C" { #endif -/* If NAME is readable and is a regular file, return it. If the error is - ENAMETOOLONG, truncate any too-long path components, and if the - result is a readable file, return that. Otherwise return NULL. */ - +/* If NAME is readable and is a regular file, return it (as is). If the + error is ENAMETOOLONG, truncate any too-long path components, and if + the result is a readable file, return that (in the same memory, since + it only got shorter). Otherwise return NULL. */ extern KPSEDLL string kpathsea_readable_file (kpathsea kpse, string name); #if defined (KPSE_COMPAT_API) |