lib/fwriting.c

2020-09-24 Thread Tim Rice


On line 24 of lib/fwriting.c we see
/* This file is not used on systems that have the __fwritable function,

Should that not be __fwriting instead of __fwritable ?


-- 
Tim RiceMultitalents
t...@multitalents.net





Re: patch: stdio fix for UnixWare

2020-09-24 Thread Tim Rice
On Thu, 24 Sep 2020, Tim Rice wrote:

> 
> Hi Bruno,
> 
> On Fri, 25 Sep 2020, Bruno Haible wrote:
> 
> > Tim Rice wrote:
> > > I've attached a patch to address the fact that UnixWare does not have
> > > stdio_ext.h but has some __X() stdio helper functions.
> > 
> > In which header file are they declared? Can you show these declarations,
> > please?
> > 
> > Bruno
> 
> stdio.h
> 
> extern size_t   __fbufsiz(FILE *);
> extern int  __filbuf(FILE *);
> extern int  __flbf(FILE *);
> extern int  __flsbuf(int, FILE *);
> extern size_t   __fpending(FILE *);
> extern void __fpurge(FILE *);
> extern int  __freadable(FILE *);
> extern int  __freading(FILE *);
> extern int  __fwritable(FILE *);
> extern int  __fwriting(FILE *);
> extern void _flushlbf(void);

This may be if interest also. (also stdio.h)

#define __flbf(p) ((void)sizeof(__filbuf(p)), ((FILE *)(p))->__flag & _IOLBF)
#define __freading(p) ((void)sizeof(__filbuf(p)), ((FILE *)(p))->__flag & 
_IOREAD)
#define __fwriting(p) ((void)sizeof(__filbuf(p)), ((FILE *)(p))->__flag & 
_IOWRT)
#define __freadable(p) (__freading(p) && __fpending(p))
#define __fwritable(p) (__fwriting(p) && __fpending(p) < __fbufsiz(p))

#define __fpurge(p) funflush(p)


-- 
Tim RiceMultitalents
t...@multitalents.net





Re: patch: stdio fiex for UnixWare

2020-09-24 Thread Tim Rice

Hi Paul,

On Thu, 24 Sep 2020, Paul Eggert wrote:

> On 9/24/20 1:49 PM, Tim Rice wrote:
> > Wrap "#include " in HAVE_STDIO_EXT_H insead of HAVE___X
> 
> Shouldn't this also add AC_CHECK_HEADERS_ONCE([stdio_ext.h]) to the
> corresponding .m4 files, as fpending.m4 and getpass.m4 already do?

Seems reasonable.
I've attached stdio_ext_m4.patch


-- 
Tim RiceMultitalents
t...@multitalents.net
ChangeLog
2020-09-24  Tim Rice  
* m4/fbufmode.m4: add AC_CHECK_HEADERS_ONCE([stdio_ext.h])
* m4/fpurge.m4: Likewise.
* m4/freadable.m4: Likewise.
* m4/freadahead.m4: Likewise.
* m4/freading.m4: Likewise.
* m4/freadptr.m4: Likewise.
* m4/fseterr.m4: Likewise.
* m4/fwritable.m4: Likewise.
* m4/fwriting.m4: Likewise.

diff --git a/m4/fbufmode.m4 b/m4/fbufmode.m4
index 87e76e0d7..99f835e5e 100644
--- a/m4/fbufmode.m4
+++ b/m4/fbufmode.m4
@@ -6,6 +6,7 @@ dnl with or without modifications, as long as this notice is 
preserved.
 
 AC_DEFUN([gl_FUNC_FBUFMODE],
 [
+  AC_CHECK_HEADERS_ONCE([stdio_ext.h])
   dnl Prerequisites of lib/fbufmode.c.
   AC_CHECK_FUNCS_ONCE([__flbf __fbufsize])
 ])
diff --git a/m4/fpurge.m4 b/m4/fpurge.m4
index 0796a6f0e..6bc3c937a 100644
--- a/m4/fpurge.m4
+++ b/m4/fpurge.m4
@@ -8,6 +8,7 @@ AC_DEFUN([gl_FUNC_FPURGE],
 [
   AC_REQUIRE([gl_STDIO_H_DEFAULTS])
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CHECK_HEADERS_ONCE([stdio_ext.h])
   AC_CHECK_FUNCS_ONCE([fpurge])
   AC_CHECK_FUNCS_ONCE([__fpurge])
   AC_CHECK_DECLS([fpurge], , , [[#include ]])
diff --git a/m4/freadable.m4 b/m4/freadable.m4
index 3237effe0..e5a317ee8 100644
--- a/m4/freadable.m4
+++ b/m4/freadable.m4
@@ -6,5 +6,6 @@ dnl with or without modifications, as long as this notice is 
preserved.
 
 AC_DEFUN([gl_FUNC_FREADABLE],
 [
+  AC_CHECK_HEADERS_ONCE([stdio_ext.h])
   AC_CHECK_FUNCS_ONCE([__freadable])
 ])
diff --git a/m4/freadahead.m4 b/m4/freadahead.m4
index 05132b526..5d2d9af87 100644
--- a/m4/freadahead.m4
+++ b/m4/freadahead.m4
@@ -6,5 +6,6 @@ dnl with or without modifications, as long as this notice is 
preserved.
 
 AC_DEFUN([gl_FUNC_FREADAHEAD],
 [
+  AC_CHECK_HEADERS_ONCE([stdio_ext.h])
   AC_CHECK_FUNCS_ONCE([__freadahead])
 ])
diff --git a/m4/freading.m4 b/m4/freading.m4
index 440c241e4..10ad2349f 100644
--- a/m4/freading.m4
+++ b/m4/freading.m4
@@ -6,5 +6,6 @@ dnl with or without modifications, as long as this notice is 
preserved.
 
 AC_DEFUN([gl_FUNC_FREADING],
 [
+  AC_CHECK_HEADERS_ONCE([stdio_ext.h])
   AC_CHECK_FUNCS_ONCE([__freading])
 ])
diff --git a/m4/freadptr.m4 b/m4/freadptr.m4
index 799703554..88f4965e3 100644
--- a/m4/freadptr.m4
+++ b/m4/freadptr.m4
@@ -6,5 +6,6 @@ dnl with or without modifications, as long as this notice is 
preserved.
 
 AC_DEFUN([gl_FUNC_FREADPTR],
 [
+  AC_CHECK_HEADERS_ONCE([stdio_ext.h])
   AC_CHECK_FUNCS_ONCE([__freadptr])
 ])
diff --git a/m4/fseterr.m4 b/m4/fseterr.m4
index 7266579b3..64036790f 100644
--- a/m4/fseterr.m4
+++ b/m4/fseterr.m4
@@ -6,5 +6,6 @@ dnl with or without modifications, as long as this notice is 
preserved.
 
 AC_DEFUN([gl_FUNC_FSETERR],
 [
+  AC_CHECK_HEADERS_ONCE([stdio_ext.h])
   AC_CHECK_FUNCS_ONCE([__fseterr])
 ])
diff --git a/m4/fwritable.m4 b/m4/fwritable.m4
index dbe887e88..ac5d71eb4 100644
--- a/m4/fwritable.m4
+++ b/m4/fwritable.m4
@@ -6,5 +6,6 @@ dnl with or without modifications, as long as this notice is 
preserved.
 
 AC_DEFUN([gl_FUNC_FWRITABLE],
 [
+  AC_CHECK_HEADERS_ONCE([stdio_ext.h])
   AC_CHECK_FUNCS_ONCE([__fwritable])
 ])
diff --git a/m4/fwriting.m4 b/m4/fwriting.m4
index 4d7cd3ede..a87f35986 100644
--- a/m4/fwriting.m4
+++ b/m4/fwriting.m4
@@ -6,5 +6,6 @@ dnl with or without modifications, as long as this notice is 
preserved.
 
 AC_DEFUN([gl_FUNC_FWRITING],
 [
+  AC_CHECK_HEADERS_ONCE([stdio_ext.h])
   AC_CHECK_FUNCS_ONCE([__fwriting])
 ])


Re: patch: stdio fiex for UnixWare

2020-09-24 Thread Tim Rice


Hi Bruno,

On Fri, 25 Sep 2020, Bruno Haible wrote:

> Tim Rice wrote:
> > I've attached a patch to address the fact that UnixWare does not have
> > stdio_ext.h but has some __X() stdio helper functions.
> 
> In which header file are they declared? Can you show these declarations,
> please?
> 
> Bruno

stdio.h

extern size_t   __fbufsiz(FILE *);
extern int  __filbuf(FILE *);
extern int  __flbf(FILE *);
extern int  __flsbuf(int, FILE *);
extern size_t   __fpending(FILE *);
extern void __fpurge(FILE *);
extern int  __freadable(FILE *);
extern int  __freading(FILE *);
extern int  __fwritable(FILE *);
extern int  __fwriting(FILE *);
extern void _flushlbf(void);

-- 
Tim RiceMultitalents
t...@multitalents.net





Re: patch: stdio fiex for UnixWare

2020-09-24 Thread Bruno Haible
Tim Rice wrote:
> I've attached a patch to address the fact that UnixWare does not have
> stdio_ext.h but has some __X() stdio helper functions.

In which header file are they declared? Can you show these declarations,
please?

Bruno




Re: patch: stdio fiex for UnixWare

2020-09-24 Thread Paul Eggert

On 9/24/20 1:49 PM, Tim Rice wrote:

Wrap "#include " in HAVE_STDIO_EXT_H insead of HAVE___X


Shouldn't this also add AC_CHECK_HEADERS_ONCE([stdio_ext.h]) to the 
corresponding .m4 files, as fpending.m4 and getpass.m4 already do?




Re: lib/fbufmode.c

2020-09-24 Thread Tim Rice


Never mind, I can't read today.

On Thu, 24 Sep 2020, Tim Rice wrote:

> 
> This does not look right.
> ---
> 57#elif defined _IOERR/* AIX, HP-UX, IRIX, OSF/1, 
> Solaris, OpenServer, mingw, MSVC, NonStop Kernel, OpenVMS */
> 58# if defined WINDOWS_OPAQUE_FILE
> 59  if (fp_->_flag & 0x100)
> 60return _IOFBF; /* Impossible to distinguish _IOFBF and _IOLBF.  */
> 61  else
> 62return _IONBF;
> 63# else
> 64#  if HAVE___FLBF   /* Solaris >= 7, UnixWare 7.1.4 >= 
> MP4 */
> 65  if (__flbf (fp))
> 66return _IOLBF;
> 67#  else
> 68  if (fp_->_flag & _IOLBF)
> 69return _IOLBF;
> 70#  endif
> 71  if (fp_->_flag & _IONBF)
> 72return _IONBF;
> 73  return _IOFBF;
> 74# endif
> 75#elif defined __UCLIBC__/* uClibc */
> ---
> 
> Lines 71 and 72 look like they should not be there since if
> there is no __flbf, lines 68 and 69 cover that.
> 
> 

-- 
Tim RiceMultitalents(707) 456-1146
t...@multitalents.net





lib/fbufmode.c

2020-09-24 Thread Tim Rice


This does not look right.
---
57  #elif defined _IOERR/* AIX, HP-UX, IRIX, OSF/1, 
Solaris, OpenServer, mingw, MSVC, NonStop Kernel, OpenVMS */
58  # if defined WINDOWS_OPAQUE_FILE
59if (fp_->_flag & 0x100)
60  return _IOFBF; /* Impossible to distinguish _IOFBF and _IOLBF.  */
61else
62  return _IONBF;
63  # else
64  #  if HAVE___FLBF   /* Solaris >= 7, UnixWare 7.1.4 >= 
MP4 */
65if (__flbf (fp))
66  return _IOLBF;
67  #  else
68if (fp_->_flag & _IOLBF)
69  return _IOLBF;
70  #  endif
71if (fp_->_flag & _IONBF)
72  return _IONBF;
73return _IOFBF;
74  # endif
75  #elif defined __UCLIBC__/* uClibc */
---

Lines 71 and 72 look like they should not be there since if
there is no __flbf, lines 68 and 69 cover that.

-- 
Tim RiceMultitalents
t...@multitalents.net





patch: stdio fiex for UnixWare

2020-09-24 Thread Tim Rice

I've attached a patch to address the fact that UnixWare does not have
stdio_ext.h but has some __X() stdio helper functions.

Wrap "#include " in HAVE_STDIO_EXT_H insead of HAVE___X

-- 
Tim RiceMultitalents
t...@multitalents.net
diff --git a/ChangeLog b/ChangeLog
index 5c4d8f849..51e074bd3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2020-09-24  Tim Rice  
+   UnixWare does not have stdio_ext.h but has some __X() stdio
+   helper functions.
+   * lib/fbufmode.c: Wrap "#include " in HAVE_STDIO_EXT_H
+   * lib/fpurge.c: Likewise.
+   * lib/freadable.h: Likewise.
+   * lib/freadahead.h: Likewise.
+   * lib/freading.h: Likewise.
+   * lib/freadptr.h: Likewise.
+   * lib/fseterr.h: Likewise.
+   * lib/fwritable.h: Likewise.
+   * lib/fwriting.h: Likewise.
+
 2020-09-23  Paul Eggert  
 
regex: fix ignore-case Turkish bug
diff --git a/lib/fbufmode.c b/lib/fbufmode.c
index 65a5cfc82..ec8afd510 100644
--- a/lib/fbufmode.c
+++ b/lib/fbufmode.c
@@ -19,7 +19,7 @@
 /* Specification.  */
 #include "fbufmode.h"
 
-#if HAVE___FLBF
+#if HAVE_STDIO_EXT_H
 # include 
 #endif
 
@@ -61,7 +61,7 @@ fbufmode (FILE *fp)
   else
 return _IONBF;
 # else
-#  if HAVE___FLBF   /* Solaris >= 7 */
+#  if HAVE___FLBF   /* Solaris >= 7, UnixWare 7.1.4 >= MP4 */
   if (__flbf (fp))
 return _IOLBF;
 #  else
diff --git a/lib/fpurge.c b/lib/fpurge.c
index f05da5abb..2af81a605 100644
--- a/lib/fpurge.c
+++ b/lib/fpurge.c
@@ -19,7 +19,7 @@
 /* Specification.  */
 #include 
 
-#if HAVE___FPURGE   /* glibc >= 2.2, Haiku, Solaris >= 7, 
Android API >= 23 */
+#if HAVE_STDIO_EXT_H/* glibc >= 2.2, Haiku, Solaris >= 7, 
Android API >= 23 */
 # include 
 #endif
 #include 
@@ -29,7 +29,7 @@
 int
 fpurge (FILE *fp)
 {
-#if HAVE___FPURGE   /* glibc >= 2.2, Haiku, Solaris >= 7, 
Android API >= 23, musl libc */
+#if HAVE___FPURGE   /* glibc >= 2.2, Haiku, Solaris >= 7, 
Android API >= 23, musl libc, UnixWare 7.1.4 >= MP4 */
 
   __fpurge (fp);
   /* The __fpurge function does not have a return value.  */
diff --git a/lib/freadable.h b/lib/freadable.h
index 5a17e4a03..c664b7d26 100644
--- a/lib/freadable.h
+++ b/lib/freadable.h
@@ -22,9 +22,11 @@
STREAM must not be wide-character oriented.
The result doesn't change until the stream is closed or re-opened.  */
 
-#if HAVE___FREADABLE /* glibc >= 2.2, Solaris >= 7, Android API >= 23, musl 
libc */
+#if HAVE___FREADABLE /* glibc >= 2.2, Solaris >= 7, Android API >= 23, musl 
libc, UnixWare 7.1.4 >= MP4 */
 
-# include 
+# if HAVE_STDIO_EXT_H
+#  include 
+# endif
 # define freadable(stream) (__freadable (stream) != 0)
 
 #else
diff --git a/lib/freadahead.h b/lib/freadahead.h
index b971d5a06..d76b306ac 100644
--- a/lib/freadahead.h
+++ b/lib/freadahead.h
@@ -29,7 +29,9 @@
 
 #if HAVE___FREADAHEAD /* musl libc */
 
-# include 
+# if HAVE_STDIO_EXT_H
+#  include 
+# endif
 # define freadahead(stream) __freadahead (stream)
 
 #else
diff --git a/lib/freading.h b/lib/freading.h
index 6c5592ec0..11deadc2d 100644
--- a/lib/freading.h
+++ b/lib/freading.h
@@ -33,9 +33,11 @@
STREAM must not be wide-character oriented.  */
 
 #if HAVE___FREADING && (!defined __GLIBC__ || defined __UCLIBC__ || __GLIBC__ 
> 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7))
-/* Solaris >= 7, Android API >= 29, not glibc >= 2.2, but glibc >= 2.7, or 
musl libc  */
+/* Solaris >= 7, Android API >= 29, not glibc >= 2.2, but glibc >= 2.7, or 
musl libc, UnixWare 7.1.4 >= MP4 */
 
-# include 
+# if HAVE_STDIO_EXT_H
+#  include 
+# endif
 # define freading(stream) (__freading (stream) != 0)
 
 #else
diff --git a/lib/freadptr.h b/lib/freadptr.h
index 07d2d727d..fc91a0b32 100644
--- a/lib/freadptr.h
+++ b/lib/freadptr.h
@@ -30,7 +30,9 @@
 
 #if HAVE___FREADPTR /* musl libc */
 
-# include 
+# if HAVE_STDIO_EXT_H
+#  include 
+# endif
 # define freadptr(stream,sizep) __freadptr (stream, sizep)
 
 #else
diff --git a/lib/fseterr.h b/lib/fseterr.h
index bbeb6619f..81ca5b4d2 100644
--- a/lib/fseterr.h
+++ b/lib/fseterr.h
@@ -25,7 +25,9 @@
 
 #if HAVE___FSETERR /* musl libc */
 
-# include 
+# if HAVE_STDIO_EXT_H
+#  include 
+# endif
 # define fseterr(fp) __fseterr (fp)
 
 #else
diff --git a/lib/fwritable.h b/lib/fwritable.h
index 44c760cf3..d8a705d34 100644
--- a/lib/fwritable.h
+++ b/lib/fwritable.h
@@ -22,9 +22,11 @@
STREAM must not be wide-character oriented.
The result doesn't change until the stream is closed or re-opened.  */
 
-#if HAVE___FWRITABLE /* glibc >= 2.2, Solaris >= 7, Android API >= 23, musl 
libc */
+#if HAVE___FWRITABLE /* glibc >= 2.2, Solaris >= 7, Android API >= 23, musl 
libc, UnixWare 7.1.4 >= MP4 */
 
-# include 
+# if HAVE_STDIO_EXT_H
+#  include 
+# endif
 # define fwritable(stream) (__fwritable (stream) != 0)
 
 #else
diff --git a/lib/fwriting.h b/lib/fwriting.h
index 111e3dcb5..961e8a963 100644
---