From: Bruno Haible Date: Sat, 28 Mar 2020 19:03:44 +0000 (+0100) Subject: Update after gnulib changed. X-Git-Tag: v0.20.2~79 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=56f8f6ff561e18758a3701563974f2cad69ad057;p=thirdparty%2Fgettext.git Update after gnulib changed. * gnulib-local/lib/regex_internal.h.diff: Update. * gnulib-local/lib/unistd.in.h.diff: Update. * gettext-runtime/intl/filename.h: New file, from gnulib. * gettext-runtime/intl/dcigettext.c (ISSLASH, HAS_DEVICE, IS_ABSOLUTE_PATH, IS_PATH_WITH_DIR): Remove macros. Instead, include filename.h. (IS_ABSOLUTE_FILE_NAME, IS_RELATIVE_FILE_NAME, IS_FILE_NAME_WITH_DIR): New macros. (DCIGETTEXT): Use IS_RELATIVE_FILE_NAME, IS_FILE_NAME_WITH_DIR. * gettext-runtime/intl/l10nflist.c (ISSLASH, HAS_DEVICE, IS_ABSOLUTE_PATH): Remove macros. Instead, include filename.h. (IS_ABSOLUTE_FILE_NAME, IS_RELATIVE_FILE_NAME): New macros. (_nl_make_l10nflist): Use IS_RELATIVE_FILE_NAME. * gettext-runtime/intl/Makefile.am (EXTRA_DIST): Add filename.h. (l10nflist.lo, dcigettext.lo): Depend on it. * Makefile.am (distcheck-hook): Check also gettext-runtime/intl/filename.h. * gettext-runtime/intl/lock.c: Update from gnulib. * gettext-runtime/intl/lock.h: Likewise. * gettext-runtime/intl/relocatable.c: Likewise. * gettext-tools/src/locating-rule.c (locating_rule_list_locate): Use IS_RELATIVE_FILE_NAME instead of IS_ABSOLUTE_PATH. * gettext-tools/src/open-catalog.c (try_open_catalog_file): Likewise. * gettext-tools/src/xgettext.c (main, xgettext_open): Likewise. * libtextstyle/lib/color.c (style_file_lookup): Use IS_FILE_NAME_WITH_DIR instead of IS_PATH_WITH_DIR. --- diff --git a/.gitignore b/.gitignore index 593ca1f51..96a3b8bf9 100644 --- a/.gitignore +++ b/.gitignore @@ -148,6 +148,8 @@ /gettext-tools/libgettextpo/intprops.h /gettext-tools/libgettextpo/inttypes.in.h /gettext-tools/libgettextpo/itold.c +/gettext-tools/libgettextpo/lc-charset-dispatch.c +/gettext-tools/libgettextpo/lc-charset-dispatch.h /gettext-tools/libgettextpo/libunistring.valgrind /gettext-tools/libgettextpo/limits.in.h /gettext-tools/libgettextpo/localcharset.c @@ -159,9 +161,13 @@ /gettext-tools/libgettextpo/markup.c /gettext-tools/libgettextpo/markup.h /gettext-tools/libgettextpo/mbrtowc.c +/gettext-tools/libgettextpo/mbrtowc-impl.h +/gettext-tools/libgettextpo/mbrtowc-impl-utf8.h /gettext-tools/libgettextpo/mbsinit.c /gettext-tools/libgettextpo/mbswidth.c /gettext-tools/libgettextpo/mbswidth.h +/gettext-tools/libgettextpo/mbtowc-lock.c +/gettext-tools/libgettextpo/mbtowc-lock.h /gettext-tools/libgettextpo/memchr.c /gettext-tools/libgettextpo/memchr.valgrind /gettext-tools/libgettextpo/minmax.h diff --git a/Makefile.am b/Makefile.am index 7a854fe06..be8a2c928 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ ## Makefile for the toplevel directory of GNU gettext -## Copyright (C) 1995-2019 Free Software Foundation, Inc. +## Copyright (C) 1995-2020 Free Software Foundation, Inc. ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -86,6 +86,7 @@ distcheck-hook: cmp -s $(srcdir)/gettext-runtime/m4/xsize.m4 $(srcdir)/gettext-tools/gnulib-m4/xsize.m4 cmp -s $(srcdir)/gettext-runtime/libasprintf/gnulib-m4/intmax_t.m4 $(srcdir)/gettext-tools/gnulib-m4/intmax_t.m4 test "`sed 1,16d $(srcdir)/gettext-runtime/intl/arg-nonnull.h | md5sum`" = "`sed 1,16d $(srcdir)/gettext-tools/gnulib-lib/arg-nonnull.h | md5sum`" + test "`sed 1,15d $(srcdir)/gettext-runtime/intl/filename.h | md5sum`" = "`sed 1,15d $(srcdir)/gettext-tools/gnulib-lib/filename.h | md5sum`" test "`sed 1,16d $(srcdir)/gettext-runtime/intl/flexmember.h | md5sum`" = "`sed 1,19d $(srcdir)/gettext-tools/gnulib-lib/flexmember.h | md5sum`" test "`sed 1,16d $(srcdir)/gettext-runtime/intl/localcharset.h | md5sum`" = "`sed 1,16d $(srcdir)/gettext-tools/gnulib-lib/localcharset.h | md5sum`" test "`sed 1,16d $(srcdir)/gettext-runtime/intl/localcharset.c | md5sum`" = "`sed 1,16d $(srcdir)/gettext-tools/gnulib-lib/localcharset.c | md5sum`" diff --git a/gettext-runtime/intl/Makefile.am b/gettext-runtime/intl/Makefile.am index 3a58a8202..4c11c9fca 100644 --- a/gettext-runtime/intl/Makefile.am +++ b/gettext-runtime/intl/Makefile.am @@ -1,6 +1,6 @@ ## Makefile for the gettext-runtime/intl and gettext-tools/intl subdirectories ## of GNU gettext. -## Copyright (C) 1995-1998, 2000-2007, 2009-2019 Free Software Foundation, Inc. +## Copyright (C) 1995-1998, 2000-2007, 2009-2020 Free Software Foundation, Inc. ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU Lesser General Public License as published by @@ -84,6 +84,7 @@ EXTRA_DIST += \ lock.h windows-mutex.h windows-rwlock.h windows-recmutex.h windows-once.h windows-initguard.h \ relocatable.h \ arg-nonnull.h \ + filename.h \ flexmember.h \ localename-table.in.h \ setlocale_null.h \ @@ -314,9 +315,9 @@ hash-string.lo: ../config.h $(srcdir)/hash-string.h loadmsgcat.lo: ../config.h $(srcdir)/gettextP.h libgnuintl.h $(srcdir)/gmo.h $(srcdir)/loadinfo.h $(srcdir)/lock.h $(srcdir)/windows-mutex.h $(srcdir)/windows-rwlock.h $(srcdir)/windows-recmutex.h $(srcdir)/windows-once.h $(srcdir)/windows-initguard.h $(srcdir)/hash-string.h $(srcdir)/plural-exp.h localealias.lo: ../config.h $(srcdir)/gettextP.h libgnuintl.h $(srcdir)/gmo.h $(srcdir)/loadinfo.h $(srcdir)/lock.h $(srcdir)/windows-mutex.h $(srcdir)/windows-rwlock.h $(srcdir)/windows-recmutex.h $(srcdir)/windows-once.h $(srcdir)/windows-initguard.h $(srcdir)/relocatable.h textdomain.lo: ../config.h $(srcdir)/gettextP.h libgnuintl.h $(srcdir)/gmo.h $(srcdir)/loadinfo.h $(srcdir)/lock.h $(srcdir)/windows-mutex.h $(srcdir)/windows-rwlock.h $(srcdir)/windows-recmutex.h $(srcdir)/windows-once.h $(srcdir)/windows-initguard.h -l10nflist.lo: ../config.h $(srcdir)/loadinfo.h +l10nflist.lo: ../config.h $(srcdir)/loadinfo.h $(srcdir)/filename.h explodename.lo: ../config.h $(srcdir)/loadinfo.h -dcigettext.lo: ../config.h $(srcdir)/gettextP.h libgnuintl.h $(srcdir)/gmo.h $(srcdir)/loadinfo.h $(srcdir)/lock.h $(srcdir)/windows-mutex.h $(srcdir)/windows-rwlock.h $(srcdir)/windows-recmutex.h $(srcdir)/windows-once.h $(srcdir)/windows-initguard.h $(srcdir)/localcharset.h $(srcdir)/plural-exp.h $(srcdir)/hash-string.h $(srcdir)/tsearch.h $(srcdir)/tsearch.c $(srcdir)/eval-plural.h +dcigettext.lo: ../config.h $(srcdir)/gettextP.h libgnuintl.h $(srcdir)/gmo.h $(srcdir)/loadinfo.h $(srcdir)/lock.h $(srcdir)/windows-mutex.h $(srcdir)/windows-rwlock.h $(srcdir)/windows-recmutex.h $(srcdir)/windows-once.h $(srcdir)/windows-initguard.h $(srcdir)/localcharset.h $(srcdir)/plural-exp.h $(srcdir)/hash-string.h $(srcdir)/tsearch.h $(srcdir)/tsearch.c $(srcdir)/eval-plural.h $(srcdir)/filename.h dcngettext.lo: ../config.h $(srcdir)/gettextP.h libgnuintl.h $(srcdir)/gmo.h $(srcdir)/loadinfo.h $(srcdir)/lock.h $(srcdir)/windows-mutex.h $(srcdir)/windows-rwlock.h $(srcdir)/windows-recmutex.h $(srcdir)/windows-once.h $(srcdir)/windows-initguard.h dngettext.lo: ../config.h $(srcdir)/gettextP.h libgnuintl.h $(srcdir)/gmo.h $(srcdir)/loadinfo.h $(srcdir)/lock.h $(srcdir)/windows-mutex.h $(srcdir)/windows-rwlock.h $(srcdir)/windows-recmutex.h $(srcdir)/windows-once.h $(srcdir)/windows-initguard.h ngettext.lo: ../config.h $(srcdir)/gettextP.h libgnuintl.h $(srcdir)/gmo.h $(srcdir)/loadinfo.h $(srcdir)/lock.h $(srcdir)/windows-mutex.h $(srcdir)/windows-rwlock.h $(srcdir)/windows-recmutex.h $(srcdir)/windows-once.h $(srcdir)/windows-initguard.h diff --git a/gettext-runtime/intl/dcigettext.c b/gettext-runtime/intl/dcigettext.c index f73f8dbe1..267e42536 100644 --- a/gettext-runtime/intl/dcigettext.c +++ b/gettext-runtime/intl/dcigettext.c @@ -1,5 +1,5 @@ /* Implementation of the internal dcigettext function. - Copyright (C) 1995-2019 Free Software Foundation, Inc. + Copyright (C) 1995-2020 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -203,26 +203,12 @@ static void *mempcpy (void *dest, const void *src, size_t n); # define PATH_MAX _POSIX_PATH_MAX #endif -/* Pathname support. - ISSLASH(C) tests whether C is a directory separator character. - IS_ABSOLUTE_PATH(P) tests whether P is an absolute path. If it is not, - it may be concatenated to a directory pathname. - IS_PATH_WITH_DIR(P) tests whether P contains a directory specification. - */ -#if defined _WIN32 || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ - /* Win32, Cygwin, OS/2, DOS */ -# define ISSLASH(C) ((C) == '/' || (C) == '\\') -# define HAS_DEVICE(P) \ - ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \ - && (P)[1] == ':') -# define IS_ABSOLUTE_PATH(P) (ISSLASH ((P)[0]) || HAS_DEVICE (P)) -# define IS_PATH_WITH_DIR(P) \ - (strchr (P, '/') != NULL || strchr (P, '\\') != NULL || HAS_DEVICE (P)) +#ifdef _LIBC +# define IS_ABSOLUTE_FILE_NAME(P) ((P)[0] == '/') +# define IS_RELATIVE_FILE_NAME(P) (! IS_ABSOLUTE_FILE_NAME (P)) +# define IS_FILE_NAME_WITH_DIR(P) (strchr ((P), '/') != NULL) #else - /* Unix */ -# define ISSLASH(C) ((C) == '/') -# define IS_ABSOLUTE_PATH(P) ISSLASH ((P)[0]) -# define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL) +# include "filename.h" #endif /* Whether to support different locales in different threads. */ @@ -620,7 +606,7 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2, { dirname = binding->dirname; #endif - if (!IS_ABSOLUTE_PATH (dirname)) + if (IS_RELATIVE_FILE_NAME (dirname)) { /* We have a relative path. Make it absolute now. */ size_t dirname_len = strlen (dirname) + 1; @@ -706,7 +692,7 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2, /* When this is a SUID binary we must not allow accessing files outside the dedicated directories. */ - if (ENABLE_SECURE && IS_PATH_WITH_DIR (single_locale)) + if (ENABLE_SECURE && IS_FILE_NAME_WITH_DIR (single_locale)) /* Ingore this entry. */ continue; } diff --git a/gettext-runtime/intl/filename.h b/gettext-runtime/intl/filename.h new file mode 100644 index 000000000..013531244 --- /dev/null +++ b/gettext-runtime/intl/filename.h @@ -0,0 +1,110 @@ +/* Basic filename support macros. + Copyright (C) 2001-2004, 2007-2020 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* From Paul Eggert and Jim Meyering. */ + +#ifndef _FILENAME_H +#define _FILENAME_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Filename support. + ISSLASH(C) tests whether C is a directory separator + character. + HAS_DEVICE(Filename) tests whether Filename contains a device + specification. + FILE_SYSTEM_PREFIX_LEN(Filename) length of the device specification + at the beginning of Filename, + index of the part consisting of + alternating components and slashes. + FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE + 1 when a non-empty device specification + can be followed by an empty or relative + part, + 0 when a non-empty device specification + must be followed by a slash, + 0 when device specification don't exist. + IS_ABSOLUTE_FILE_NAME(Filename) + tests whether Filename is independent of + any notion of "current directory". + IS_RELATIVE_FILE_NAME(Filename) + tests whether Filename may be concatenated + to a directory filename. + Note: On native Windows, OS/2, DOS, "c:" is neither an absolute nor a + relative file name! + IS_FILE_NAME_WITH_DIR(Filename) tests whether Filename contains a device + or directory specification. + */ +#if defined _WIN32 || defined __CYGWIN__ \ + || defined __EMX__ || defined __MSDOS__ || defined __DJGPP__ + /* Native Windows, Cygwin, OS/2, DOS */ +# define ISSLASH(C) ((C) == '/' || (C) == '\\') + /* Internal macro: Tests whether a character is a drive letter. */ +# define _IS_DRIVE_LETTER(C) \ + (((C) >= 'A' && (C) <= 'Z') || ((C) >= 'a' && (C) <= 'z')) + /* Help the compiler optimizing it. This assumes ASCII. */ +# undef _IS_DRIVE_LETTER +# define _IS_DRIVE_LETTER(C) \ + (((unsigned int) (C) | ('a' - 'A')) - 'a' <= 'z' - 'a') +# define HAS_DEVICE(Filename) \ + (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':') +# define FILE_SYSTEM_PREFIX_LEN(Filename) (HAS_DEVICE (Filename) ? 2 : 0) +# ifdef __CYGWIN__ +# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0 +# else + /* On native Windows, OS/2, DOS, the system has the notion of a + "current directory" on each drive. */ +# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1 +# endif +# if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE +# define IS_ABSOLUTE_FILE_NAME(Filename) \ + ISSLASH ((Filename)[FILE_SYSTEM_PREFIX_LEN (Filename)]) +# else +# define IS_ABSOLUTE_FILE_NAME(Filename) \ + (ISSLASH ((Filename)[0]) || HAS_DEVICE (Filename)) +# endif +# define IS_RELATIVE_FILE_NAME(Filename) \ + (! (ISSLASH ((Filename)[0]) || HAS_DEVICE (Filename))) +# define IS_FILE_NAME_WITH_DIR(Filename) \ + (strchr ((Filename), '/') != NULL || strchr ((Filename), '\\') != NULL \ + || HAS_DEVICE (Filename)) +#else + /* Unix */ +# define ISSLASH(C) ((C) == '/') +# define HAS_DEVICE(Filename) ((void) (Filename), 0) +# define FILE_SYSTEM_PREFIX_LEN(Filename) ((void) (Filename), 0) +# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0 +# define IS_ABSOLUTE_FILE_NAME(Filename) ISSLASH ((Filename)[0]) +# define IS_RELATIVE_FILE_NAME(Filename) (! ISSLASH ((Filename)[0])) +# define IS_FILE_NAME_WITH_DIR(Filename) (strchr ((Filename), '/') != NULL) +#endif + +/* Deprecated macros. For backward compatibility with old users of the + 'filename' module. */ +#define IS_ABSOLUTE_PATH IS_ABSOLUTE_FILE_NAME +#define IS_PATH_WITH_DIR IS_FILE_NAME_WITH_DIR + + +#ifdef __cplusplus +} +#endif + +#endif /* _FILENAME_H */ diff --git a/gettext-runtime/intl/l10nflist.c b/gettext-runtime/intl/l10nflist.c index 95667ca7f..7d3c9690c 100644 --- a/gettext-runtime/intl/l10nflist.c +++ b/gettext-runtime/intl/l10nflist.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2016, 2018 Free Software Foundation, Inc. +/* Copyright (C) 1995-2016, 2018, 2020 Free Software Foundation, Inc. Contributed by Ulrich Drepper , 1995. This program is free software: you can redistribute it and/or modify @@ -60,22 +60,11 @@ static char *stpcpy (char *dest, const char *src); # endif #endif -/* Pathname support. - ISSLASH(C) tests whether C is a directory separator character. - IS_ABSOLUTE_PATH(P) tests whether P is an absolute path. If it is not, - it may be concatenated to a directory pathname. - */ -#if defined _WIN32 || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ - /* Win32, Cygwin, OS/2, DOS */ -# define ISSLASH(C) ((C) == '/' || (C) == '\\') -# define HAS_DEVICE(P) \ - ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \ - && (P)[1] == ':') -# define IS_ABSOLUTE_PATH(P) (ISSLASH ((P)[0]) || HAS_DEVICE (P)) +#ifdef _LIBC +# define IS_ABSOLUTE_FILE_NAME(P) ((P)[0] == '/') +# define IS_RELATIVE_FILE_NAME(P) (! IS_ABSOLUTE_FILE_NAME (P)) #else - /* Unix */ -# define ISSLASH(C) ((C) == '/') -# define IS_ABSOLUTE_PATH(P) ISSLASH ((P)[0]) +# include "filename.h" #endif /* Define function which are usually not available. */ @@ -183,7 +172,7 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, /* If LANGUAGE contains an absolute directory specification, we ignore DIRLIST. */ - if (IS_ABSOLUTE_PATH (language)) + if (!IS_RELATIVE_FILE_NAME (language)) dirlist_len = 0; /* Allocate room for the full file name. */ diff --git a/gettext-runtime/intl/lock.c b/gettext-runtime/intl/lock.c index 4755c6909..f509e217e 100644 --- a/gettext-runtime/intl/lock.c +++ b/gettext-runtime/intl/lock.c @@ -1,5 +1,5 @@ /* Locking in multithreaded situations. - Copyright (C) 2005-2008, 2012, 2017, 2019 Free Software Foundation, Inc. + Copyright (C) 2005-2008, 2012, 2017, 2019-2020 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -718,6 +718,26 @@ glthread_once_singlethreaded (pthread_once_t *once_control) return 0; } +# if !(PTHREAD_IN_USE_DETECTION_HARD || USE_POSIX_THREADS_WEAK) + +int +glthread_once_multithreaded (pthread_once_t *once_control, + void (*init_function) (void)) +{ + int err = pthread_once (once_control, init_function); + if (err == ENOSYS) + { + /* This happens on FreeBSD 11: The pthread_once function in libc returns + ENOSYS. */ + if (glthread_once_singlethreaded (once_control)) + init_function (); + return 0; + } + return err; +} + +# endif + #endif /* ========================================================================= */ diff --git a/gettext-runtime/intl/lock.h b/gettext-runtime/intl/lock.h index 017e95f7e..d65f2c033 100644 --- a/gettext-runtime/intl/lock.h +++ b/gettext-runtime/intl/lock.h @@ -1,5 +1,5 @@ /* Locking in multithreaded situations. - Copyright (C) 2005-2008, 2017-2019 Free Software Foundation, Inc. + Copyright (C) 2005-2008, 2017-2020 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -505,10 +505,19 @@ extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *l typedef pthread_once_t gl_once_t; # define gl_once_define(STORAGECLASS, NAME) \ STORAGECLASS pthread_once_t NAME = PTHREAD_ONCE_INIT; -# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ - (pthread_in_use () \ - ? pthread_once (ONCE_CONTROL, INITFUNCTION) \ - : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0)) +# if PTHREAD_IN_USE_DETECTION_HARD || USE_POSIX_THREADS_WEAK +# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ + (pthread_in_use () \ + ? pthread_once (ONCE_CONTROL, INITFUNCTION) \ + : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0)) +# else +# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ + (pthread_in_use () \ + ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \ + : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0)) +extern int glthread_once_multithreaded (pthread_once_t *once_control, + void (*init_function) (void)); +# endif extern int glthread_once_singlethreaded (pthread_once_t *once_control); # ifdef __cplusplus diff --git a/gettext-runtime/intl/relocatable.c b/gettext-runtime/intl/relocatable.c index afb1a276b..209a618e9 100644 --- a/gettext-runtime/intl/relocatable.c +++ b/gettext-runtime/intl/relocatable.c @@ -74,8 +74,8 @@ #define true 1 /* Pathname support. - ISSLASH(C) tests whether C is a directory separator character. - IS_PATH_WITH_DIR(P) tests whether P contains a directory specification. + ISSLASH(C) tests whether C is a directory separator character. + IS_FILE_NAME_WITH_DIR(P) tests whether P contains a directory specification. */ #if (defined _WIN32 && !defined __CYGWIN__) || defined __EMX__ || defined __DJGPP__ /* Native Windows, OS/2, DOS */ @@ -83,13 +83,13 @@ # define HAS_DEVICE(P) \ ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \ && (P)[1] == ':') -# define IS_PATH_WITH_DIR(P) \ +# define IS_FILE_NAME_WITH_DIR(P) \ (strchr (P, '/') != NULL || strchr (P, '\\') != NULL || HAS_DEVICE (P)) # define FILE_SYSTEM_PREFIX_LEN(P) (HAS_DEVICE (P) ? 2 : 0) #else /* Unix */ # define ISSLASH(C) ((C) == '/') -# define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL) +# define IS_FILE_NAME_WITH_DIR(P) (strchr (P, '/') != NULL) # define FILE_SYSTEM_PREFIX_LEN(P) 0 #endif @@ -333,7 +333,7 @@ DllMain (HINSTANCE module_handle, DWORD event, LPVOID reserved) /* Shouldn't happen. */ return FALSE; - if (!IS_PATH_WITH_DIR (location)) + if (!IS_FILE_NAME_WITH_DIR (location)) /* Shouldn't happen. */ return FALSE; diff --git a/gettext-tools/src/locating-rule.c b/gettext-tools/src/locating-rule.c index f78b437ca..06e725b5a 100644 --- a/gettext-tools/src/locating-rule.c +++ b/gettext-tools/src/locating-rule.c @@ -1,5 +1,5 @@ /* XML resource locating rules - Copyright (C) 2015 Free Software Foundation, Inc. + Copyright (C) 2015, 2020 Free Software Foundation, Inc. This file was written by Daiki Ueno , 2015. @@ -194,18 +194,11 @@ locating_rule_list_locate (struct locating_rule_list_ty *rules, const char *filename, const char *name) { - const char *target = NULL; size_t i; for (i = 0; i < rules->nitems; i++) { - if (IS_ABSOLUTE_PATH (filename)) - { - target = locating_rule_match (&rules->items[i], filename, name); - if (target != NULL) - return target; - } - else + if (IS_RELATIVE_FILE_NAME (filename)) { int j; @@ -213,6 +206,7 @@ locating_rule_list_locate (struct locating_rule_list_ty *rules, { const char *dir = dir_list_nth (j); char *new_filename; + const char *target; if (dir == NULL) break; @@ -225,6 +219,14 @@ locating_rule_list_locate (struct locating_rule_list_ty *rules, return target; } } + else + { + const char *target = + locating_rule_match (&rules->items[i], filename, name); + + if (target != NULL) + return target; + } } return NULL; diff --git a/gettext-tools/src/open-catalog.c b/gettext-tools/src/open-catalog.c index 1627c9d96..b904886ff 100644 --- a/gettext-tools/src/open-catalog.c +++ b/gettext-tools/src/open-catalog.c @@ -1,5 +1,5 @@ /* open-po - search for .po file along search path list and open for reading - Copyright (C) 1995-1996, 2000-2003, 2005-2009 Free Software Foundation, Inc. + Copyright (C) 1995-1996, 2000-2003, 2005-2009, 2020 Free Software Foundation, Inc. Written by Ulrich Drepper , April 1995. This program is free software: you can redistribute it and/or modify @@ -57,26 +57,8 @@ try_open_catalog_file (const char *input_name, char **real_file_name_p) return stdin; } - /* We have a real name for the input file. If the name is absolute, - try the various extensions, but ignore the directory search list. */ - if (IS_ABSOLUTE_PATH (input_name)) - { - for (k = 0; k < SIZEOF (extension); ++k) - { - file_name = xconcatenated_filename ("", input_name, extension[k]); - - ret_val = fopen (file_name, "r"); - if (ret_val != NULL || errno != ENOENT) - { - /* We found the file. */ - *real_file_name_p = file_name; - return ret_val; - } - - free (file_name); - } - } - else + /* We have a real name for the input file. */ + if (IS_RELATIVE_FILE_NAME (input_name)) { /* For relative file names, look through the directory search list, trying the various extensions. If no directory search list is @@ -89,6 +71,7 @@ try_open_catalog_file (const char *input_name, char **real_file_name_p) ret_val = fopen (file_name, "r"); if (ret_val != NULL || errno != ENOENT) { + /* We found the file. */ *real_file_name_p = file_name; return ret_val; } @@ -96,6 +79,25 @@ try_open_catalog_file (const char *input_name, char **real_file_name_p) free (file_name); } } + else + { + /* The name is not relative. Try the various extensions, but ignore the + directory search list. */ + for (k = 0; k < SIZEOF (extension); ++k) + { + file_name = xconcatenated_filename ("", input_name, extension[k]); + + ret_val = fopen (file_name, "r"); + if (ret_val != NULL || errno != ENOENT) + { + /* We found the file. */ + *real_file_name_p = file_name; + return ret_val; + } + + free (file_name); + } + } /* File does not exist. */ *real_file_name_p = xstrdup (input_name); diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c index b9cd243f5..a6bceddcf 100644 --- a/gettext-tools/src/xgettext.c +++ b/gettext-tools/src/xgettext.c @@ -1,5 +1,5 @@ /* Extracts strings from C source file to Uniforum style .po file. - Copyright (C) 1995-1998, 2000-2016, 2018-2019 Free Software Foundation, Inc. + Copyright (C) 1995-1998, 2000-2016, 2018-2020 Free Software Foundation, Inc. Written by Ulrich Drepper , April 1995. This program is free software: you can redistribute it and/or modify @@ -746,11 +746,11 @@ xgettext cannot work without keywords to look for")); the special name "-" we write to stdout. */ if (output_file) { - if (IS_ABSOLUTE_PATH (output_file) || strcmp (output_file, "-") == 0) - file_name = xstrdup (output_file); - else + if (IS_RELATIVE_FILE_NAME (output_file) && strcmp (output_file, "-") != 0) /* Please do NOT add a .po suffix! */ file_name = xconcatenated_filename (output_dir, output_file, NULL); + else + file_name = xstrdup (output_file); } else if (strcmp (default_domain, "-") == 0) file_name = "-"; @@ -1700,16 +1700,7 @@ xgettext_open (const char *fn, logical_file_name = xstrdup (new_name); fp = stdin; } - else if (IS_ABSOLUTE_PATH (fn)) - { - new_name = xstrdup (fn); - fp = fopen (fn, "r"); - if (fp == NULL) - error (EXIT_FAILURE, errno, - _("error while opening \"%s\" for reading"), fn); - logical_file_name = xstrdup (new_name); - } - else + else if (IS_RELATIVE_FILE_NAME (fn)) { int j; @@ -1740,6 +1731,15 @@ xgettext_open (const char *fn, file name which was searched for. */ logical_file_name = xstrdup (fn); } + else + { + new_name = xstrdup (fn); + fp = fopen (fn, "r"); + if (fp == NULL) + error (EXIT_FAILURE, errno, + _("error while opening \"%s\" for reading"), fn); + logical_file_name = xstrdup (new_name); + } *logical_file_name_p = logical_file_name; *real_file_name_p = new_name; diff --git a/gnulib-local/lib/regex_internal.h.diff b/gnulib-local/lib/regex_internal.h.diff index bfcc24200..b546622bd 100644 --- a/gnulib-local/lib/regex_internal.h.diff +++ b/gnulib-local/lib/regex_internal.h.diff @@ -1,7 +1,7 @@ *** lib/regex_internal.h.orig Mon May 24 12:36:55 2010 --- lib/regex_internal.h Mon May 24 12:35:46 2010 *************** -*** 476,482 **** +*** 468,474 **** # define MAX(a,b) ((a) < (b) ? (b) : (a)) #endif @@ -9,7 +9,7 @@ #define re_realloc(p,t,n) ((t *) realloc (p, (n) * sizeof (t))) #define re_free(p) free (p) ---- 476,482 ---- +--- 468,474 ---- # define MAX(a,b) ((a) < (b) ? (b) : (a)) #endif diff --git a/gnulib-local/lib/unistd.in.h.diff b/gnulib-local/lib/unistd.in.h.diff index 5c131cdb5..d265068a6 100644 --- a/gnulib-local/lib/unistd.in.h.diff +++ b/gnulib-local/lib/unistd.in.h.diff @@ -1,14 +1,15 @@ --- unistd.in.h 2017-05-15 19:05:30.449063823 +0200 +++ unistd.in.h.new 2017-05-15 19:14:39.145268786 +0200 -@@ -136,6 +136,10 @@ +@@ -141,7 +141,11 @@ + /* Get getopt(), optarg, optind, opterr, optopt. */ --#if @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT +-#if @GNULIB_GETOPT_POSIX@ && @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT +/* Also, don't include inside libgettextpo, because we use + the getopt module only in gettext-tools/gnulib-lib/, not in + gettext-tools/libgettextpo/, but there is only a single + GNULIB_UNISTD_H_GETOPT variable for both. */ -+#if @GNULIB_UNISTD_H_GETOPT@ && !defined GTPO_CONFIG_H && !defined _GL_SYSTEM_GETOPT ++#if @GNULIB_GETOPT_POSIX@ && @GNULIB_UNISTD_H_GETOPT@ && !defined GTPO_CONFIG_H && !defined _GL_SYSTEM_GETOPT # include # include #endif diff --git a/libtextstyle/.gitignore b/libtextstyle/.gitignore index 360366b0d..96f7f07df 100644 --- a/libtextstyle/.gitignore +++ b/libtextstyle/.gitignore @@ -55,6 +55,7 @@ /lib/float+.h /lib/float.c /lib/float.in.h +/lib/fstat.c /lib/fsync.c /lib/full-write.c /lib/full-write.h @@ -95,6 +96,8 @@ /lib/limits.in.h /lib/log10.c /lib/malloc.c +/lib/malloca.c +/lib/malloca.h /lib/math.c /lib/math.in.h /lib/memchr.c @@ -113,6 +116,7 @@ /lib/obstack.h /lib/ostream.oo.c /lib/ostream.oo.h +/lib/pathmax.h /lib/printf-args.c /lib/printf-args.h /lib/printf-parse.c @@ -134,6 +138,11 @@ /lib/sigprocmask.c /lib/size_max.h /lib/snprintf.c +/lib/stat.c +/lib/stat-time.c +/lib/stat-time.h +/lib/stat-w32.c +/lib/stat-w32.h /lib/stdarg.in.h /lib/stdbool.in.h /lib/stddef.in.h @@ -149,6 +158,7 @@ /lib/styled-ostream.oo.c /lib/styled-ostream.oo.h /lib/sys-limits.h +/lib/sys_stat.in.h /lib/sys_types.in.h /lib/term-ostream.oo.c /lib/term-ostream.oo.h @@ -461,6 +471,8 @@ core /lib/stdlib.h-t /lib/string.h /lib/string.h-t +/lib/sys/stat.h +/lib/sys/stat.h-t /lib/sys/types.h /lib/sys/types.h-t /lib/textstyle/stdbool.h-t diff --git a/libtextstyle/lib/color.c b/libtextstyle/lib/color.c index 5f080c9ce..7689c1b1c 100644 --- a/libtextstyle/lib/color.c +++ b/libtextstyle/lib/color.c @@ -1,5 +1,5 @@ /* Color and styling handling. - Copyright (C) 2006-2008, 2019 Free Software Foundation, Inc. + Copyright (C) 2006-2008, 2019-2020 Free Software Foundation, Inc. Written by Bruno Haible , 2006. This program is free software: you can redistribute it and/or modify @@ -388,7 +388,7 @@ print_color_test () static const char * style_file_lookup (const char *file_name, const char *stylesdir_after_install) { - if (!IS_PATH_WITH_DIR (file_name)) + if (!IS_FILE_NAME_WITH_DIR (file_name)) { /* It's a file name without a directory specification. If it does not exist in the current directory... */