changeset 10433:02b0f65bfbfc

New module 'perror'.
author Bruno Haible <bruno@clisp.org>
date Sun, 14 Sep 2008 13:50:55 +0200
parents f9f54364dbd0
children a95a7e53bca3
files ChangeLog MODULES.html.sh doc/posix-functions/perror.texi lib/stdio.in.h m4/stdio_h.m4 modules/stdio
diffstat 6 files changed, 40 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2008-09-14  Bruno Haible  <bruno@clisp.org>
+
+	New module 'perror'.
+	* lib/stdio.in.h (perror): New declaration.
+	* lib/perror.c: New file.
+	* m4/perror.m4: New file.
+	* modules/perror: New file.
+	* MODULES.html.sh (Support for systems lacking POSIX:2001): Add perror.
+	* doc/posix-functions/perror.texi: Mention the perror module.
+	* m4/stdio_h.m4 (gl_STDIO_H_DEFAULTS): Initialize GNULIB_PERROR,
+	REPLACE_PERROR.
+	* modules/stdio (Makefile.am): Substitute GNULIB_PERROR,
+	REPLACE_PERROR.
+
 2008-09-14  Bruno Haible  <bruno@clisp.org>
 
 	* modules/stdio (Makefile.am): Reorder to match the order in
--- a/MODULES.html.sh
+++ b/MODULES.html.sh
@@ -2112,6 +2112,7 @@
   func_module mkstemp
   func_module netinet_in
   func_module open
+  func_module perror
   func_module poll
   func_module printf-posix
   func_module readlink
--- a/doc/posix-functions/perror.texi
+++ b/doc/posix-functions/perror.texi
@@ -4,10 +4,14 @@
 
 POSIX specification: @url{http://www.opengroup.org/susv3xsh/perror.html}
 
-Gnulib module: ---
+Gnulib module: perror
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function does not support the error values that are specified by POSIX
+but not defined by the system, on some platforms:
+OpenBSD 4.0, OSF/1 5.1, mingw.
 @end itemize
 
 Portability problems not fixed by Gnulib:
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -395,6 +395,22 @@
    getline (l, s, f))
 #endif
 
+#if @GNULIB_PERROR@
+# if @REPLACE_PERROR@
+#  define perror rpl_perror
+/* Print a message to standard error, describing the value of ERRNO,
+   (if STRING is not NULL and not empty) prefixed with STRING and ": ",
+   and terminated with a newline.  */
+extern void perror (const char *string);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef perror
+# define perror(s) \
+    (GL_LINK_WARNING ("perror is not always POSIX compliant - " \
+                      "use gnulib module perror for portability"), \
+     perror (s))
+#endif
+
 #ifdef __cplusplus
 }
 #endif
--- a/m4/stdio_h.m4
+++ b/m4/stdio_h.m4
@@ -39,6 +39,7 @@
   GNULIB_FFLUSH=0;               AC_SUBST([GNULIB_FFLUSH])
   GNULIB_GETDELIM=0;             AC_SUBST([GNULIB_GETDELIM])
   GNULIB_GETLINE=0;              AC_SUBST([GNULIB_GETLINE])
+  GNULIB_PERROR=0;               AC_SUBST([GNULIB_PERROR])
   dnl Assume proper GNU behavior unless another module says otherwise.
   REPLACE_FPRINTF=0;             AC_SUBST([REPLACE_FPRINTF])
   REPLACE_VFPRINTF=0;            AC_SUBST([REPLACE_VFPRINTF])
@@ -66,6 +67,7 @@
   HAVE_DECL_GETDELIM=1;          AC_SUBST([HAVE_DECL_GETDELIM])
   HAVE_DECL_GETLINE=1;           AC_SUBST([HAVE_DECL_GETLINE])
   REPLACE_GETLINE=0;             AC_SUBST([REPLACE_GETLINE])
+  REPLACE_PERROR=0;              AC_SUBST([REPLACE_PERROR])
 ])
 
 dnl Code shared by fseeko and ftello.  Determine if large files are supported,
--- a/modules/stdio
+++ b/modules/stdio
@@ -43,6 +43,7 @@
 	      -e 's|@''GNULIB_FFLUSH''@|$(GNULIB_FFLUSH)|g' \
 	      -e 's|@''GNULIB_GETDELIM''@|$(GNULIB_GETDELIM)|g' \
 	      -e 's|@''GNULIB_GETLINE''@|$(GNULIB_GETLINE)|g' \
+	      -e 's|@''GNULIB_PERROR''@|$(GNULIB_PERROR)|g' \
 	      -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \
 	      -e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \
 	      -e 's|@''REPLACE_PRINTF''@|$(REPLACE_PRINTF)|g' \
@@ -67,6 +68,7 @@
 	      -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \
 	      -e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \
 	      -e 's|@''REPLACE_GETLINE''@|$(REPLACE_GETLINE)|g' \
+	      -e 's|@''REPLACE_PERROR''@|$(REPLACE_PERROR)|g' \
 	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
 	      < $(srcdir)/stdio.in.h; \
 	} > $@-t