Remove SVR2 support from mountlist

2018-10-14 Thread Andrew Borodin
Hi!

A year ago (commit 467061a2014d742a27eb8d4498e8d09fb3225d53), the SVR2 support
was removed from fsusage.

Should it be removed from mountlist either?

-- 
Andrew



[PATCH] libc-config: merge from glibc

2018-10-14 Thread Paul Eggert
* lib/cdefs.h (__glibc_has_attribute): New macro.
---
 ChangeLog   | 3 +++
 lib/cdefs.h | 6 ++
 2 files changed, 9 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 31cf9791d..dcabc939b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2018-10-15  Paul Eggert  
 
+   libc-config: merge from glibc
+   * lib/cdefs.h (__glibc_has_attribute): New macro.
+
regex: depend on libc-config
* modules/regex (Depends-on): Add libc-config.
This is needed after the recent autoupdate from glibc.
diff --git a/lib/cdefs.h b/lib/cdefs.h
index b16453124..98cf74995 100644
--- a/lib/cdefs.h
+++ b/lib/cdefs.h
@@ -409,6 +409,12 @@
 # define __glibc_likely(cond)  (cond)
 #endif
 
+#ifdef __has_attribute
+# define __glibc_has_attribute(attr)   __has_attribute (attr)
+#else
+# define __glibc_has_attribute(attr)   0
+#endif
+
 #if (!defined _Noreturn \
  && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
  &&  !__GNUC_PREREQ (4,7))
-- 
2.17.2




[PATCH] regex: depend on libc-config

2018-10-14 Thread Paul Eggert
* modules/regex (Depends-on): Add libc-config.
This is needed after the recent autoupdate from glibc.
---
 ChangeLog | 6 ++
 modules/regex | 1 +
 2 files changed, 7 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index acd7e51bc..31cf9791d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2018-10-15  Paul Eggert  
+
+   regex: depend on libc-config
+   * modules/regex (Depends-on): Add libc-config.
+   This is needed after the recent autoupdate from glibc.
+
 2018-10-14  Bruno Haible  
 
localename: Add support for per-thread locales on Solaris 11.4.
diff --git a/modules/regex b/modules/regex
index b3cdf042b..278510c4c 100644
--- a/modules/regex
+++ b/modules/regex
@@ -21,6 +21,7 @@ btowc   [test $ac_use_included_regex = yes]
 builtin-expect  [test $ac_use_included_regex = yes]
 intprops[test $ac_use_included_regex = yes]
 langinfo[test $ac_use_included_regex = yes]
+libc-config [test $ac_use_included_regex = yes]
 lock  [test "$ac_cv_gnu_library_2_1:$ac_use_included_regex" = no:yes]
 memcmp  [test $ac_use_included_regex = yes]
 memmove [test $ac_use_included_regex = yes]
-- 
2.17.2




Re: Current requirements for Java

2018-10-14 Thread Akim Demaille
Hi all!

> Le 14 oct. 2018 à 22:24, Bruno Haible  a écrit :
> 
> The essential reference is the timeline of Java releases:
> https://en.wikipedia.org/wiki/Java_version_history

Thanks!

> As you can see, Java specification levels 1.3, 1.4, 1.5 are outdated for
> more than 3 years. And level 1.6 will be outdated in December 2018.
> So, why not move to
>  gt_JAVACOMP([1.7], [1.7])
> already now?

It does make sense.  Someday, I should check if these newer features
should be used in the generated code.


> What this change implies?
>  1) You must adapt your source code (or bison-generated code) to be compliant
> with Java 1.7. In particular, you cannot have variables or methods named
> 'assert' any more, since this is a keyword since Java 1.4. And a couple
> of things like that.

Luckily, nothing was needed.


>  2) You cannot use GCJ as Java implementation any more, since it stayed
> at level 1.5 / 1.6 before it was discontinued. (It was dropped in GCC 7.)
>  3) Users who want to use the compiled .class / .jar files will need Java 7
> or newer. But this is not a problem, since the industry has already
> moved from Java 6 to Java 7 (mostly).

That’s what I was truly worried about, thanks!


Thanks to Paul and you.  I installed this in Bison.

commit cf0e35460e26e3bbbcfd1220d606a38151c86327
Author: Akim Demaille 
Date:   Mon Oct 15 06:36:52 2018 +0200

java: bump to Java SE 7

macOS 10.14 no longer supports versions of Java earlier than 5.
And Java 6 will be deprecated by the end of this year.  So let's move
our requirement to Java 7.
Reported by Yu Yijun.
https://lists.gnu.org/archive/html/bug-bison/2018-09/msg00060.html
Suggested by Paul Eggert and Bruno Haible.
http://lists.gnu.org/archive/html/bug-gnulib/2018-10/msg00094.html

* configure.ac: Require Java 7, both compiler and runtime.

diff --git a/configure.ac b/configure.ac
index 7cd0964d..a569ef7c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -267,7 +267,7 @@ AM_MISSING_PROG([AUTOM4TE], [autom4te])
 # Needed by tests/atlocal.in.
 AC_SUBST([GCC])
 
-gt_JAVACOMP([1.3], [1.4])
+gt_JAVACOMP([1.7], [1.7])
 gt_JAVAEXEC
 
 AC_CONFIG_FILES([Makefile




Re: doc: update for Solaris 11.4

2018-10-14 Thread Paul Eggert

Bruno Haible wrote:

   - They added 'timegm' and 'timelocal', but since gnulib does not have a
 unit test for them, I have no idea how buggy they are.
 Paul, do you have a unit test for these functions in some corner?


I'm afraid not, and it's low priority. timelocal is merely a nonstandard alias 
for mktime, and portable programs should use mktime. Although there is some use 
for timegm, the Gnulib-using code that I maintain calls the much more-general 
function mktime_z from the time_rz module, and if I had time to write tests I'd 
rather write them against mktime_z.




Re: Current requirements for Java

2018-10-14 Thread Bruno Haible
Hi Akim,

> In Bison we have a Java backend.  We use gnulib to handle the
> Java tool chain.  In particular, in configure.ac we have
> 
> gt_JAVACOMP([1.3], [1.4])
> gt_JAVAEXEC
> 
> it worked like a charm for years.
> 
> Until macOS Mojave; Yu Yijun reported that we get:
> 
>   467. java.at:367: testing Calculator  ...
>   ./java.at:367: bison -fno-caret -o Calc.java Calc.y
>   ./java.at:367: $SHELL ../../../javacomp.sh Calc.java
>   stderr:
>   warning: [options] bootstrap class path not set in conjunction with -source 
> 1.3
>   error: Source option 1.3 is no longer supported. Use 1.6 or later.
>   error: Target option 1.4 is no longer supported. Use 1.6 or later.
> ...
> I have absolutely no idea what that change implies.  What are
> the other project based on gnulib that use this?  What is the
> current policy for updating the requirements?

The essential reference is the timeline of Java releases:
https://en.wikipedia.org/wiki/Java_version_history

As you can see, Java specification levels 1.3, 1.4, 1.5 are outdated for
more than 3 years. And level 1.6 will be outdated in December 2018.
So, why not move to
  gt_JAVACOMP([1.7], [1.7])
already now?

What this change implies?
  1) You must adapt your source code (or bison-generated code) to be compliant
 with Java 1.7. In particular, you cannot have variables or methods named
 'assert' any more, since this is a keyword since Java 1.4. And a couple
 of things like that.
  2) You cannot use GCJ as Java implementation any more, since it stayed
 at level 1.5 / 1.6 before it was discontinued. (It was dropped in GCC 7.)
  3) Users who want to use the compiled .class / .jar files will need Java 7
 or newer. But this is not a problem, since the industry has already
 moved from Java 6 to Java 7 (mostly).

Gettext moved from
  gt_JAVACOMP([1.3], [1.1])
to
  gt_JAVACOMP([1.5], [1.6])
recently, as a consequence of this bug report:


There is no policy; you update these gt_JAVACOMP invocations as you like.

Bruno




Re: Current requirements for Java

2018-10-14 Thread Paul Eggert

Akim Demaille wrote:

he changed

   CONF_JAVAC='javac -target 1.4 -source 1.3'

to

   CONF_JAVAC='javac -target 1.6 -source 1.6'

and had all the tests pass without any error.

I have absolutely no idea what that change implies.


It means the Java compiler accepts Java 6 source code and generates class files 
that target Java 6 runtimes and later (instead of the previous practice of 
accepting Java 1.3 source and generating class files that target Java 1.4 
runtimes and later). Apparently the Apple version of Java no longer will accept 
Java 5 and earlier, or generate class files that target runtimes from Java 5 and 
earlier.


As Java versions prior to Java 6 are no longer supported by Oracle (or by 
anybody else, as far as I know) it's reasonable for Apple to drop support for 
these older versions, and it's reasonable for Bison to do so as well. So I would 
install the change into Bison. This shouldn't require any change to Gnulib.




Current requirements for Java

2018-10-14 Thread Akim Demaille
In Bison we have a Java backend.  We use gnulib to handle the
Java tool chain.  In particular, in configure.ac we have

gt_JAVACOMP([1.3], [1.4])
gt_JAVAEXEC

it worked like a charm for years.

Until macOS Mojave; Yu Yijun reported that we get:

  467. java.at:367: testing Calculator  ...
  ./java.at:367: bison -fno-caret -o Calc.java Calc.y
  ./java.at:367: $SHELL ../../../javacomp.sh Calc.java
  stderr:
  warning: [options] bootstrap class path not set in conjunction with -source 
1.3
  error: Source option 1.3 is no longer supported. Use 1.6 or later.
  error: Target option 1.4 is no longer supported. Use 1.6 or later.
  stdout:
  ./java.at:367: exit code was 2, expected 0
  467. java.at:367: 467. Calculator  (java.at:367): FAILED (java.at:367)

In
https://lists.gnu.org/archive/html/bug-bison/2018-09/msg00060.html
he changed

  CONF_JAVAC='javac -target 1.4 -source 1.3'

to

  CONF_JAVAC='javac -target 1.6 -source 1.6'

and had all the tests pass without any error.

I have absolutely no idea what that change implies.  What are
the other project based on gnulib that use this?  What is the
current policy for updating the requirements?

Thanks!


localename: Add support for per-thread locales on Solaris 11.4

2018-10-14 Thread Bruno Haible
Solaris 11.4 has added uselocale(), newlocale(), etc.
However, the data structure of locale_t does not contain the locale category
names. But this is essential for gettext() to work, when a per-thread
locale has been set! gettext() relies on the gnulib 'localename' module
for fetching the name of the LC_MESSAGES category. The way the Solaris
implementors designed it, the LC_MESSAGES category can *only* be used
to fetch the 'yesexpr' and 'noexpr' strings, *and nothing else*.

That's a design for minimum extensibility, when nowadays maximum
extensibility ought to be commonplace in programmers' thinking.

In order to overcome this, the 'localename' module has to keep its own
hash table (locale_t -> set of names, one per category). This, in turn,
requires overriding 'newlocale', 'duplocale', and 'freelocale'.

With this patch, test-localename passes on Solaris 11.4. Also tested on
all other platforms that have 'uselocale'.


2018-10-14  Bruno Haible  

localename: Add support for per-thread locales on Solaris 11.4.
* lib/locale.in.h (newlocale, freelocale): New declarations.
(duplocale): Declare also when the 'localename' module requests it.
* lib/localename.c (struniq_hash_node): Renamed from hash_node.
(STRUNIQ_HASH_TABLE_SIZE): Renamed from HASH_TABLE_SIZE.
(struniq): Update.
(struct locale_categories_names, struct locale_hash_node): New types.
(LOCALE_HASH_TABLE_SIZE): New constant.
(locale_hash_table, locale_lock): New variables.
(pointer_hash, get_locale_t_name): New functions.
(newlocale, duplocale, freelocale): New overridden functions.
(gl_locale_name_thread_unsafe): Use get_locale_t_name.
* m4/intlsolaris.m4: New file.
* m4/localename.m4 (gl_LOCALENAME): Require gl_LOCALE_H_DEFAULTS. Invoke
gt_INTL_SOLARIS. Set HAVE_NEWLOCALE, HAVE_DUPLOCALE, HAVE_FREELOCALE,
REPLACE_NEWLOCALE, REPLACE_DUPLOCALE, REPLACE_FREELOCALE.
* m4/locale_h.m4 (gl_LOCALE_H): Test whether newlocale, freelocale are
declared.
(gl_LOCALE_H_DEFAULTS): Initialize GNULIB_LOCALENAME, HAVE_NEWLOCALE,
HAVE_FREELOCALE, REPLACE_NEWLOCALE, REPLACE_FREELOCALE.
* modules/locale (Makefile.am): Substitute GNULIB_LOCALENAME,
HAVE_NEWLOCALE, HAVE_FREELOCALE, REPLACE_NEWLOCALE, REPLACE_FREELOCALE.
* modules/localename (Files): Add intlsolaris.m4.
(Depends-on): Add 'locale'.
(configure.ac): Invoke gl_LOCALE_MODULE_INDICATOR.
* tests/test-locale-c++.cc (newlocale, freelocale): Prepare for checking
the signatures.

diff --git a/lib/locale.in.h b/lib/locale.in.h
index 804261d..be11cee 100644
--- a/lib/locale.in.h
+++ b/lib/locale.in.h
@@ -190,7 +190,34 @@ _GL_WARN_ON_USE (setlocale, "setlocale works differently 
on native Windows - "
 # endif
 #endif
 
-#if @GNULIB_DUPLOCALE@
+#if /*@GNULIB_NEWLOCALE@ ||*/ (@GNULIB_LOCALENAME@ && @HAVE_NEWLOCALE@)
+# if @REPLACE_NEWLOCALE@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef newlocale
+#   define newlocale rpl_newlocale
+#  endif
+_GL_FUNCDECL_RPL (newlocale, locale_t,
+  (int category_mask, const char *name, locale_t base)
+  _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (newlocale, locale_t,
+  (int category_mask, const char *name, locale_t base));
+# else
+#  if @HAVE_NEWLOCALE@
+_GL_CXXALIAS_SYS (newlocale, locale_t,
+  (int category_mask, const char *name, locale_t base));
+#  endif
+# endif
+# if @HAVE_NEWLOCALE@
+_GL_CXXALIASWARN (newlocale);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef newlocale
+# if HAVE_RAW_DECL_NEWLOCALE
+_GL_WARN_ON_USE (newlocale, "newlocale is not portable");
+# endif
+#endif
+
+#if @GNULIB_DUPLOCALE@ || (@GNULIB_LOCALENAME@ && @HAVE_DUPLOCALE@)
 # if @REPLACE_DUPLOCALE@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   undef duplocale
@@ -214,6 +241,29 @@ _GL_WARN_ON_USE (duplocale, "duplocale is buggy on some 
glibc systems - "
 # endif
 #endif
 
+#if /*@GNULIB_FREELOCALE@ ||*/ (@GNULIB_LOCALENAME@ && @HAVE_FREELOCALE@)
+# if @REPLACE_FREELOCALE@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef freelocale
+#   define freelocale rpl_freelocale
+#  endif
+_GL_FUNCDECL_RPL (freelocale, void, (locale_t locale) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (freelocale, void, (locale_t locale));
+# else
+#  if @HAVE_FREELOCALE@
+_GL_CXXALIAS_SYS (freelocale, void, (locale_t locale));
+#  endif
+# endif
+# if @HAVE_FREELOCALE@
+_GL_CXXALIASWARN (freelocale);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef freelocale
+# if HAVE_RAW_DECL_FREELOCALE
+_GL_WARN_ON_USE (freelocale, "freelocale is not portable");
+# endif
+#endif
+
 #endif /* _@GUARD_PREFIX@_LOCALE_H */
 #endif /* _@GUARD_PREFIX@_LOCALE_H */
 #endif /* !(__need_locale_t || _GL_ALREADY_INCLUDING_LOCALE_H) */
diff --git a/lib/localename.c b/lib/localename.c
index f9f9cc9..93fee9b 100644
--- 

Re: Fix crash in gnulib-tool.py under Python 2.6 and lower

2018-10-14 Thread Darshit Shah
* Tim Rühsen  [181014 15:07]:
> On 13.10.18 23:19, Darshit Shah wrote:
> > Well, I don't think there will be a Python 4 for a very long time. The major
> > version number changes only for a large backwards incompatibility. It's 
> > taken
> > them ~10 years and people still not on Python 3.
> > 
> > Anyways, I don't think this will break even with v4. Since the check is only
> > for ensuring the minimum version number.
> 
> I was referring to
> if not PYTHON3 or sys.version_info[1] < 7:
> 
> PYTHON3 is true for any python version except 2 (maybe rename it to
> PYTHON2 and inverse the logic ?).
> 
> But the 'or sys.version_info[1] < 7' would be true for python 4.0, so it
> would print "Python version must be atleast 2.7. Exiting.".
> 
That is a stupid typo that I left behind in the code. As Gisle pointed out in
the other email, it should be "and"
> 
> > 
> > * Tim Rühsen  [181013 23:05]:
> >> On 13.10.18 21:28, Darshit Shah wrote:
> >>> gnulib-tool.py will currently crash immediately on start if the underlying
> >>> Python version is 2.6 or lower. The immediate crash that is seen occurs 
> >>> during
> >>> the check for the Python version. The check uses a syntax which was only
> >>> introduced in 2.7. I haven't checked, but I believe that the rest of the 
> >>> script
> >>> also uses 2.7+ syntax. Hence, I have also added a check to the script to 
> >>> exit
> >>> out if the version of Python being used is less than 2.7.
> >>
> >> Thanks so much !
> >>
> >> But could make this a bit more future-proof. I was just thinking that
> >> python version 4.0 would break your checks.
> >>
> >> Regards, Tim
> >>
> > 
> > 
> > 
> > 
> 




-- 
Thanking You,
Darshit Shah
PGP Fingerprint: 7845 120B 07CB D8D6 ECE5 FF2B 2A17 43ED A91A 35B6


signature.asc
Description: PGP signature


Re: Fix crash in gnulib-tool.py under Python 2.6 and lower

2018-10-14 Thread Tim Rühsen
On 13.10.18 23:19, Darshit Shah wrote:
> Well, I don't think there will be a Python 4 for a very long time. The major
> version number changes only for a large backwards incompatibility. It's taken
> them ~10 years and people still not on Python 3.
> 
> Anyways, I don't think this will break even with v4. Since the check is only
> for ensuring the minimum version number.

I was referring to
if not PYTHON3 or sys.version_info[1] < 7:

PYTHON3 is true for any python version except 2 (maybe rename it to
PYTHON2 and inverse the logic ?).

But the 'or sys.version_info[1] < 7' would be true for python 4.0, so it
would print "Python version must be atleast 2.7. Exiting.".


> 
> * Tim Rühsen  [181013 23:05]:
>> On 13.10.18 21:28, Darshit Shah wrote:
>>> gnulib-tool.py will currently crash immediately on start if the underlying
>>> Python version is 2.6 or lower. The immediate crash that is seen occurs 
>>> during
>>> the check for the Python version. The check uses a syntax which was only
>>> introduced in 2.7. I haven't checked, but I believe that the rest of the 
>>> script
>>> also uses 2.7+ syntax. Hence, I have also added a check to the script to 
>>> exit
>>> out if the version of Python being used is less than 2.7.
>>
>> Thanks so much !
>>
>> But could make this a bit more future-proof. I was just thinking that
>> python version 4.0 would break your checks.
>>
>> Regards, Tim
>>
> 
> 
> 
> 



signature.asc
Description: OpenPGP digital signature


Re: timevar: 3/3: use clock_gettime to get wall clock time

2018-10-14 Thread Bruno Haible
Akim Demaille wrote:
> > ‘sys' -> 'wall'
> 
> 易

The first of these characters is described by Emacs as "Not Assigned".
Time to get a newer Emacs, I guess :)

> Fixed.  Can I push it?

Sure.

Bruno




wcsnrtombs: work around Solaris 11.4 bug

2018-10-14 Thread Bruno Haible
2018-10-14  Bruno Haible  

wcsnrtombs: Work around Solaris 11.4 bug.
* m4/wcsnrtombs.m4 (gl_WCSNRTOMBS_WORKS_IN_TRADITIONAL_LOCALE): New
macro.
(gl_FUNC_WCSNRTOMBS): Invoke it.
* doc/posix-functions/wcsnrtombs.texi: Mention the Solaris bug.

diff --git a/doc/posix-functions/wcsnrtombs.texi 
b/doc/posix-functions/wcsnrtombs.texi
index 3c7800a..7641e11 100644
--- a/doc/posix-functions/wcsnrtombs.texi
+++ b/doc/posix-functions/wcsnrtombs.texi
@@ -11,6 +11,10 @@ Portability problems fixed by Gnulib:
 @item
 This function is missing on some platforms:
 Mac OS X 10.3, FreeBSD 5.2.1, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 4.3.2, 
HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 11.3, Cygwin 1.5.x, mingw, MSVC 14, 
Interix 3.5, BeOS, Android 4.4.
+@item
+This function cannot consume valid sequences of wide characters
+on some platforms:
+Solaris 11.4.
 @end itemize
 
 Portability problems not fixed by Gnulib:
diff --git a/m4/wcsnrtombs.m4 b/m4/wcsnrtombs.m4
index c04e2c1..530f60c 100644
--- a/m4/wcsnrtombs.m4
+++ b/m4/wcsnrtombs.m4
@@ -1,4 +1,4 @@
-# wcsnrtombs.m4 serial 5
+# wcsnrtombs.m4 serial 6
 dnl Copyright (C) 2008-2018 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -17,6 +17,13 @@ AC_DEFUN([gl_FUNC_WCSNRTOMBS],
   else
 if test $REPLACE_MBSTATE_T = 1; then
   REPLACE_WCSNRTOMBS=1
+else
+  gl_WCSNRTOMBS_WORKS_IN_TRADITIONAL_LOCALE
+  case "$gl_cv_func_wcsnrtombs_works_in_traditional_locale" in
+*yes) ;;
+*) REPLACE_WCSNRTOMBS=1 ;;
+  esac
+
 fi
   fi
 ])
@@ -25,3 +32,75 @@ AC_DEFUN([gl_FUNC_WCSNRTOMBS],
 AC_DEFUN([gl_PREREQ_WCSNRTOMBS], [
   :
 ])
+
+dnl Test whether wcsnrtombs works in an ISO-8859-1 locale.
+dnl Result is gl_cv_func_wcsnrtombs_works_in_traditional_locale.
+
+AC_DEFUN([gl_WCSNRTOMBS_WORKS_IN_TRADITIONAL_LOCALE],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([gt_LOCALE_FR])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether wcsnrtombs works in a traditional locale],
+[gl_cv_func_wcsnrtombs_works_in_traditional_locale],
+[
+  dnl Initial guess, used when cross-compiling or when no suitable locale
+  dnl is present.
+changequote(,)dnl
+  case "$host_os" in
+  # Guess no on Solaris.
+solaris*) gl_cv_func_wcsnrtombs_works_in_traditional_locale="guessing 
no" ;;
+  # Guess yes otherwise.
+*)gl_cv_func_wcsnrtombs_works_in_traditional_locale="guessing 
yes" ;;
+  esac
+changequote([,])dnl
+  if test $LOCALE_FR != none; then
+AC_RUN_IFELSE(
+  [AC_LANG_SOURCE([[
+#include 
+#include 
+#include 
+/* Tru64 with Desktop Toolkit C has a bug:  must be included before
+   .
+   BSD/OS 4.0.1 has a bug: ,  and  must be
+   included before .  */
+#include 
+#include 
+#include 
+#include 
+int main ()
+{
+  /* This fails on Solaris 11.4.  */
+  if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
+{
+  /* Locale encoding is ISO-8859-1 or ISO-8859-15.  */
+  const char original[] = "B\374\337er"; /* "Büßer" */
+  wchar_t input[10];
+  size_t ret;
+  const wchar_t *src;
+
+  #define BUFSIZE 20
+  char buf[BUFSIZE];
+  memset (buf, '_', BUFSIZE);
+
+  ret = mbstowcs (input, original, 10);
+  if (!(ret == 5))
+return 1;
+
+  src = input;
+  ret = wcsnrtombs (buf, , 6, 2, NULL);
+  if (!(ret == 2))
+return 2;
+  if (!(src == input + 2))
+return 3;
+  if (!(memcmp (buf, original, ret) == 0))
+return 4;
+}
+  return 0;
+}]])],
+  [gl_cv_func_wcsnrtombs_works_in_traditional_locale=yes],
+  [gl_cv_func_wcsnrtombs_works_in_traditional_locale=no],
+  [:])
+  fi
+])
+])




mbsnrtowcs: work around Solaris 11.4 bug

2018-10-14 Thread Bruno Haible
2018-10-14  Bruno Haible  

mbsnrtowcs: Work around Solaris 11.4 bug.
* m4/mbsnrtowcs.m4 (gl_MBSNRTOWCS_WORKS_IN_TRADITIONAL_LOCALE): New
macro.
(gl_FUNC_MBSNRTOWCS): Invoke it.
* doc/posix-functions/mbsnrtowcs.texi: Mention the Solaris bug.

diff --git a/doc/posix-functions/mbsnrtowcs.texi 
b/doc/posix-functions/mbsnrtowcs.texi
index d2e5ce0..cba6d63 100644
--- a/doc/posix-functions/mbsnrtowcs.texi
+++ b/doc/posix-functions/mbsnrtowcs.texi
@@ -11,6 +11,9 @@ Portability problems fixed by Gnulib:
 @item
 This function is missing on some platforms:
 Mac OS X 10.3, FreeBSD 5.2.1, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 4.3.2, 
HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 11.3, Cygwin 1.5.x, mingw, MSVC 14, 
Interix 3.5, BeOS, Android 4.4.
+@item
+This function produces invalid wide characters on some platforms:
+Solaris 11.4.
 @end itemize
 
 Portability problems not fixed by Gnulib:
diff --git a/m4/mbsnrtowcs.m4 b/m4/mbsnrtowcs.m4
index 3eb60b7..485a1ce 100644
--- a/m4/mbsnrtowcs.m4
+++ b/m4/mbsnrtowcs.m4
@@ -1,4 +1,4 @@
-# mbsnrtowcs.m4 serial 4
+# mbsnrtowcs.m4 serial 5
 dnl Copyright (C) 2008, 2010-2018 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -20,6 +20,12 @@ AC_DEFUN([gl_FUNC_MBSNRTOWCS],
   else
 if test $REPLACE_MBSTATE_T = 1; then
   REPLACE_MBSNRTOWCS=1
+else
+  gl_MBSNRTOWCS_WORKS_IN_TRADITIONAL_LOCALE
+  case "$gl_cv_func_mbsnrtowcs_works_in_traditional_locale" in
+*yes) ;;
+*) REPLACE_MBSNRTOWCS=1 ;;
+  esac
 fi
   fi
 ])
@@ -28,3 +34,98 @@ AC_DEFUN([gl_FUNC_MBSNRTOWCS],
 AC_DEFUN([gl_PREREQ_MBSNRTOWCS], [
   :
 ])
+
+dnl Test whether mbsnrtowcs works in an ISO-8859-1 locale.
+dnl Result is gl_cv_func_mbsnrtowcs_works_in_traditional_locale.
+
+AC_DEFUN([gl_MBSNRTOWCS_WORKS_IN_TRADITIONAL_LOCALE],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([gt_LOCALE_FR])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether mbsnrtowcs works in a traditional locale],
+[gl_cv_func_mbsnrtowcs_works_in_traditional_locale],
+[
+  dnl Initial guess, used when cross-compiling or when no suitable locale
+  dnl is present.
+changequote(,)dnl
+  case "$host_os" in
+  # Guess no on Solaris.
+solaris*) gl_cv_func_mbsnrtowcs_works_in_traditional_locale="guessing 
no" ;;
+  # Guess yes otherwise.
+*)gl_cv_func_mbsnrtowcs_works_in_traditional_locale="guessing 
yes" ;;
+  esac
+changequote([,])dnl
+  if test $LOCALE_FR != none; then
+AC_RUN_IFELSE(
+  [AC_LANG_SOURCE([[
+#include 
+#include 
+#include 
+/* Tru64 with Desktop Toolkit C has a bug:  must be included before
+   .
+   BSD/OS 4.0.1 has a bug: ,  and  must be
+   included before .  */
+#include 
+#include 
+#include 
+#include 
+int main ()
+{
+  /* This fails on Solaris 11.4:
+ mbsnrtowcs stores a wrong wide character: 0xDF instead of btowc (0xDF).  
*/
+  if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
+{
+  /* Locale encoding is ISO-8859-1 or ISO-8859-15.  */
+  char input[] = "B\374\337er"; /* "Büßer" */
+  mbstate_t state;
+  mbstate_t temp_state;
+  wchar_t wc;
+  size_t ret;
+  const char *src;
+
+  #define BUFSIZE 10
+  wchar_t buf[BUFSIZE];
+  {
+size_t i;
+for (i = 0; i < BUFSIZE; i++)
+  buf[i] = (wchar_t) 0xBADFACE;
+  }
+
+  memset (, '\0', sizeof (mbstate_t));
+
+  wc = (wchar_t) 0xBADFACE;
+  ret = mbrtowc (, input, 1, );
+  if (!(ret == 1 && wc == 'B' && mbsinit ()))
+return 1;
+  input[0] = '\0';
+
+  wc = (wchar_t) 0xBADFACE;
+  ret = mbrtowc (, input + 1, 1, );
+  if (!(ret == 1 && wctob (wc) == (unsigned char) '\374' && mbsinit 
()))
+return 2;
+  input[1] = '\0';
+
+  src = input + 2;
+  temp_state = state;
+  ret = mbsnrtowcs (NULL, , 4, 1, _state);
+  if (!(ret == 3 && src == input + 2 && mbsinit ()))
+return 3;
+
+  src = input + 2;
+  ret = mbsnrtowcs (buf, , 4, 1, );
+  if (!(ret == 1))
+return 4;
+  if (!(src == input + 3))
+return 5;
+  if (!(buf[0] == btowc ((unsigned char) '\337')))
+return 6;
+}
+  return 0;
+}]])],
+  [gl_cv_func_mbsnrtowcs_works_in_traditional_locale=yes],
+  [gl_cv_func_mbsnrtowcs_works_in_traditional_locale=no],
+  [:])
+  fi
+])
+])




doc: update for Solaris 11.4

2018-10-14 Thread Bruno Haible
Hi,

Solaris 11.4 was released in August 2018. The relevant improvements are listed
here: https://docs.oracle.com/cd/E37838_01/html/E60974/golbg.html

>From the gnulib perspective, the notable changes are:
  - They added per-thread locales: functions newlocale, *_l, etc.
  - All libnsl functions moved into libc.
  - The  and  are now standards compliant.
  - They added 'dprintf', 'euidaccess', 'secure_getenv', 'accept4', 'pipe2'.
  - 'link' and 'linkat' are now POSIX compliant. 'rename' similarly.
  - They added the functions mbsnrtowcs and wcsnrtombs, both buggy.
  - Regression: printf of infinite values is now broken: it produces "Inf"
instead of "inf".
  - Regression: strtod is now broken (cannot parse hex floats any more).
  - Regression: logb, logbf, logbl are now broken.
  - Regression: Some math functions are no longer IEEE compliant:
log, log10.
  - They added 'timegm' and 'timelocal', but since gnulib does not have a
unit test for them, I have no idea how buggy they are.
Paul, do you have a unit test for these functions in some corner?

The patch
https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=f4dda9f5c203b49b68633b7b410f7b70e77997f4
is uninteresting, except for the changes to dprintf.texi and vdprintf.texi.
You get the useful info by searching for 'Solaris 11.3' in the *.texi files.

Bruno




floor, ceil, trunc, truncf, truncl: Defeat GCC optimizations

2018-10-14 Thread Bruno Haible
On Solaris 11.4, a couple of *_LIBM variables come out wrong in config.status
(empty instead of '-lm'). The reason are apparently optimizations by GCC 7.
This fixes it.


2018-10-14  Bruno Haible  

floor, ceil, trunc, truncf, truncl: Defeat GCC optimizations.
* m4/floor.m4 (gl_FUNC_FLOOR_LIBS): Use 'floor' also through a function
pointer.
* m4/ceil.m4 (gl_FUNC_CEIL_LIBS): Use 'ceil' also through a function
pointer.
* m4/trunc.m4 (gl_FUNC_TRUNC): Use 'trunc' also through a function
pointer.
* m4/truncf.m4 (gl_FUNC_TRUNCF): Use 'truncf' also through a function
pointer.
* m4/truncl.m4 (gl_FUNC_TRUNCL): Use 'truncl' also through a function
pointer.

diff --git a/m4/ceil.m4 b/m4/ceil.m4
index 592b3f2..87199ed 100644
--- a/m4/ceil.m4
+++ b/m4/ceil.m4
@@ -1,4 +1,4 @@
-# ceil.m4 serial 11
+# ceil.m4 serial 12
 dnl Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -81,8 +81,9 @@ AC_DEFUN([gl_FUNC_CEIL_LIBS],
# define __NO_MATH_INLINES 1 /* for glibc */
#endif
#include 
+   double (*funcptr) (double) = ceil;
double x;]],
- [[x = ceil(x);]])],
+ [[x = funcptr(x) + ceil(x);]])],
   [gl_cv_func_ceil_libm=])
 if test "$gl_cv_func_ceil_libm" = "?"; then
   save_LIBS="$LIBS"
@@ -93,8 +94,9 @@ AC_DEFUN([gl_FUNC_CEIL_LIBS],
  # define __NO_MATH_INLINES 1 /* for glibc */
  #endif
  #include 
+ double (*funcptr) (double) = ceil;
  double x;]],
-   [[x = ceil(x);]])],
+   [[x = funcptr(x) + ceil(x);]])],
 [gl_cv_func_ceil_libm="-lm"])
   LIBS="$save_LIBS"
 fi
diff --git a/m4/floor.m4 b/m4/floor.m4
index 15fa84d..bef45a1 100644
--- a/m4/floor.m4
+++ b/m4/floor.m4
@@ -1,4 +1,4 @@
-# floor.m4 serial 10
+# floor.m4 serial 11
 dnl Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -77,8 +77,9 @@ AC_DEFUN([gl_FUNC_FLOOR_LIBS],
# define __NO_MATH_INLINES 1 /* for glibc */
#endif
#include 
+   double (*funcptr) (double) = floor;
double x;]],
- [[x = floor(x);]])],
+ [[x = funcptr(x) + floor(x);]])],
   [gl_cv_func_floor_libm=])
 if test "$gl_cv_func_floor_libm" = "?"; then
   save_LIBS="$LIBS"
@@ -89,8 +90,9 @@ AC_DEFUN([gl_FUNC_FLOOR_LIBS],
  # define __NO_MATH_INLINES 1 /* for glibc */
  #endif
  #include 
+ double (*funcptr) (double) = floor;
  double x;]],
-   [[x = floor(x);]])],
+   [[x = funcptr(x) + floor(x);]])],
 [gl_cv_func_floor_libm="-lm"])
   LIBS="$save_LIBS"
 fi
diff --git a/m4/trunc.m4 b/m4/trunc.m4
index 7abb8ec..1ff8f19 100644
--- a/m4/trunc.m4
+++ b/m4/trunc.m4
@@ -1,4 +1,4 @@
-# trunc.m4 serial 11
+# trunc.m4 serial 12
 dnl Copyright (C) 2007, 2010-2018 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -21,8 +21,9 @@ AC_DEFUN([gl_FUNC_TRUNC],
# define __NO_MATH_INLINES 1 /* for glibc */
#endif
#include 
+   double (*funcptr) (double) = trunc;
double x;]],
- [[x = trunc(x);]])],
+ [[x = funcptr(x) + trunc(x);]])],
   [TRUNC_LIBM=])
 if test "$TRUNC_LIBM" = "?"; then
   save_LIBS="$LIBS"
@@ -33,8 +34,9 @@ AC_DEFUN([gl_FUNC_TRUNC],
  # define __NO_MATH_INLINES 1 /* for glibc */
  #endif
  #include 
+ double (*funcptr) (double) = trunc;
  double x;]],
-   [[x = trunc(x);]])],
+   [[x = funcptr(x) + trunc(x);]])],
 [TRUNC_LIBM="-lm"])
   LIBS="$save_LIBS"
 fi
diff --git a/m4/truncf.m4 b/m4/truncf.m4
index fb4c569..fdd36ec 100644
--- a/m4/truncf.m4
+++ b/m4/truncf.m4
@@ -1,4 +1,4 @@
-# truncf.m4 serial 11
+# truncf.m4 serial 12
 dnl Copyright (C) 2007, 2010-2018 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -21,8 +21,9 @@ AC_DEFUN([gl_FUNC_TRUNCF],
# define __NO_MATH_INLINES 1 /* for glibc */
#endif
#include 
+   float (*funcptr) (float) = truncf;
float x;]],
- [[x = truncf(x);]])],
+ [[x = funcptr(x) + truncf(x);]])],
   [TRUNCF_LIBM=])
 if test "$TRUNCF_LIBM" = "?"; then
   save_LIBS="$LIBS"
@@ -33,8 +34,9 @@ AC_DEFUN([gl_FUNC_TRUNCF],
  # define __NO_MATH_INLINES 1 /* for glibc */
  #endif
  #include 
+  

Re: timevar: 3/3: use clock_gettime to get wall clock time

2018-10-14 Thread Akim Demaille



> Le 14 oct. 2018 à 09:15, Bruno Haible  a écrit :
> 
> Hi Akim,
> 
> Looks good, except for one copy mistake:
>> +  fprintf (fp, "%11.6f (%2d%%)\n", tv->elapsed.wall * 1e-9, sys);
> ‘sys' -> 'wall'

易

Fixed.  Can I push it?


Re: timevar: 3/3: use clock_gettime to get wall clock time

2018-10-14 Thread Bruno Haible
Hi Akim,

Looks good, except for one copy mistake:
> +  fprintf (fp, "%11.6f (%2d%%)\n", tv->elapsed.wall * 1e-9, sys);
'sys' -> 'wall'

Bruno




Re: timevar: 3/3: use clock_gettime to get wall clock time

2018-10-14 Thread Akim Demaille
Hi Bruno!

> Le 13 oct. 2018 à 18:11, Bruno Haible  a écrit :
> 
> Hi Akim,
> 
>> Or we filter on the percentages.
> 
> Yes, filtering on percentages is the way to go. The user doesn't
> care about contributions < 1% or < 0.5%. When people draw pie charts,
> such minimal contributions are usually combined into "Other", but
> here you can just as well omit them entirely.

That’s still very verbose with Bison, two more lines that with
the original criterion:

  CPU user  CPU systemwall clock  
 reader   0,014 ( 2%)   0,001 (15%)   0,014834 (15%)
 LR(0)0,002 ( 0%)   0,000 ( 1%)   0,002267 ( 1%)
 conflicts0,000 ( 0%)   0,000 ( 1%)   0,000590 ( 1%)
 outputting report0,029 ( 6%)   0,001 (17%)   0,030352 (17%)
 parser action tables 0,017 ( 3%)   0,000 ( 1%)   0,017086 ( 1%)
 outputting parser0,011 ( 2%)   0,001 (14%)   0,052919 (14%)
 running m4   0,405 (84%)   0,004 (46%)   0,366641 (46%)
 total time   0,481 0,008 0,487395

but I can live with that.

> 
>> diff --git a/lib/timevar.h b/lib/timevar.h
>> index ff443fed6..9ea94f71f 100644
>> --- a/lib/timevar.h
>> +++ b/lib/timevar.h
>> ...
>> +float timevar_tiny;
>> +float timevar_wall_tiny;
> 
> These declarations need 'extern', otherwise you'll get "symbol multiply
> defined » errors when linking.

Gee…  But what is wrong with me???

> In order not to fall into this trap, I like to prefix *all* declarations
> in .h file with 'extern'. Yes, it’s more verbose, but it's more systematic.

My way to avoid this is to never expose variables.


commit 29283642c0e39d3e64c555a2ed4fd71feae771a4
Author: Akim Demaille 
Date:   Fri Oct 12 06:46:09 2018 +0200

timevar: use gethrxtime to get wall clock time

clock_gettime is not portable.  gethrxtime takes the best available
option to get the wall clock time, including clock_gettime (monotonic
clock), and gettime (non monotonic).
Also, using xtime_t instead of float preserves the precision.
Suggested by Bruno Haible.

* lib/xtime.h (xtime_make): Handle overflows of nanoseconds.
* modules/timevar (Depends-on): We need gethrxtime.
We no longer use times().
(Link): Update.
* lib/timevar.h (timevar_time_def): Use xtime_t.
* lib/timevar.c (set_to_current_time): Use gethrxtime.
(timevar_print): Instead of checking whether the timings themselves
are large enough for the timevar to be printed, check the percentages.

diff --git a/ChangeLog b/ChangeLog
index ecd69df04..3d7441909 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2018-10-13  Akim Demaille  
+
+   timevar: use gethrxtime to get wall clock time
+   clock_gettime is not portable.  gethrxtime takes the best available
+   option to get the wall clock time, including clock_gettime (monotonic
+   clock), and gettime (non monotonic).
+   Also, using xtime_t instead of float preserves the precision.
+   Suggested by Bruno Haible.
+   * lib/xtime.h (xtime_make): Handle overflows of nanoseconds.
+   * modules/timevar (Depends-on): We need gethrxtime.
+   We no longer use times().
+   (Link): Update.
+   * lib/timevar.h (timevar_time_def): Use xtime_t.
+   * lib/timevar.c (set_to_current_time): Use gethrxtime.
+   (timevar_print): Instead of checking whether the timings themselves
+   are large enough for the timevar to be printed, check the percentages.
+
 2018-10-13  Akim Demaille  
 
bootstrap: fix wget command for po files.
diff --git a/lib/timevar.c b/lib/timevar.c
index 8b574e277..6059fd78c 100644
--- a/lib/timevar.c
+++ b/lib/timevar.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 
+#include "gethrxtime.h"
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
 #include "xalloc.h"
@@ -101,13 +102,20 @@ set_to_current_time (struct timevar_time_def *now)
   if (!timevar_enabled)
 return;
 
-  struct rusage rusage;
-  getrusage (RUSAGE_SELF, );
-  now->user = rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec * 1e-6;
-  now->sys  = rusage.ru_stime.tv_sec + rusage.ru_stime.tv_usec * 1e-6;
-  getrusage (RUSAGE_CHILDREN, );
-  now->user += rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec * 1e-6;
-  now->sys  += rusage.ru_stime.tv_sec + rusage.ru_stime.tv_usec * 1e-6;
+  struct rusage self;
+  getrusage (RUSAGE_SELF, );
+  struct rusage chld;
+  getrusage (RUSAGE_CHILDREN, );
+
+  now->user =
+xtime_make (self.ru_utime.tv_sec + chld.ru_utime.tv_sec,
+(self.ru_utime.tv_usec + chld.ru_utime.tv_usec) * 1000);
+
+  now->sys =
+xtime_make (self.ru_stime.tv_sec + chld.ru_stime.tv_sec,
+(self.ru_stime.tv_usec + chld.ru_stime.tv_usec) * 1000);
+
+  now->wall = gethrxtime();
 }
 
 /* Return the current time.  */
@@ -310,49 +318,34 @@ timevar_print (FILE *fp)
"", _("CPU user"), _("CPU system"), _("wall clock"));
   for (unsigned /* timevar_id_t */ id = 0; id <