[vlc-devel] [PATCH 2/3] posix: add a replacement for strerror_l

Sean McGovern gseanmcg at gmail.com
Sat Sep 12 19:23:06 CEST 2015


This function is new for POSIX 2008.
See: https://www.gnu.org/software/gnulib/manual/html_node/strerror_005fl.html.
---
 compat/strerror_l.c  |   37 +++++++++++++++++++++++++++++++++++++
 configure.ac         |    2 +-
 include/vlc_fixups.h |    5 +++++
 3 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 compat/strerror_l.c

diff --git a/compat/strerror_l.c b/compat/strerror_l.c
new file mode 100644
index 0000000..6ef7f63
--- /dev/null
+++ b/compat/strerror_l.c
@@ -0,0 +1,37 @@
+/*****************************************************************************
+ * strerror_l.c: POSIX.1-2008 strerror_l replacement
+ *****************************************************************************
+ *
+ * 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, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <errno.h>
+#include <locale.h>
+
+/* See: http://pubs.opengroup.org/onlinepubs/9699919799/functions/strerror_l.html */
+char *strerror_l(int errnum, locale_t locale)
+{
+#ifdef strerror_l
+    return strerror_l(errnum, locale);
+#else
+    errno = ENOSYS;
+    return NULL;
+#endif
+}
+
diff --git a/configure.ac b/configure.ac
index 96bc808..2e1f7f8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -551,7 +551,7 @@ need_libc=false
 dnl Check for usual libc functions
 AC_CHECK_DECLS([nanosleep],,,[#include <time.h>])
 AC_CHECK_FUNCS([daemon fcntl fstatvfs fork getenv getpwuid_r isatty lstat memalign mkostemp mmap open_memstream openat pread posix_fadvise posix_madvise setlocale stricmp strnicmp strptime uselocale pthread_cond_timedwait_monotonic_np pthread_condattr_setclock])
-AC_REPLACE_FUNCS([atof atoll dirfd fdopendir ffsll flockfile fsync getdelim getpid lldiv nrand48 poll posix_memalign rewind setenv strcasecmp strcasestr strdup strlcpy strndup strnlen strsep strtof strtok_r strtoll swab tdestroy strverscmp])
+AC_REPLACE_FUNCS([atof atoll dirfd fdopendir ffsll flockfile fsync getdelim getpid lldiv nrand48 poll posix_memalign rewind setenv strcasecmp strcasestr strdup strerror_l strlcpy strndup strnlen strsep strtof strtok_r strtoll swab tdestroy strverscmp])
 AC_CHECK_FUNCS(fdatasync,,
   [AC_DEFINE(fdatasync, fsync, [Alias fdatasync() to fsync() if missing.])
 ])
diff --git a/include/vlc_fixups.h b/include/vlc_fixups.h
index 2c3ed52..5346989 100644
--- a/include/vlc_fixups.h
+++ b/include/vlc_fixups.h
@@ -391,6 +391,11 @@ void freeaddrinfo (struct addrinfo *res);
 #define nanf(tagp) NAN
 #endif
 
+/* POSIX.1-2008 */
+#ifndef HAVE_STRERROR_L
+char *strerror_l (int, locale_t);
+#endif
+
 #ifdef _WIN32
 FILE *vlc_win32_tmpfile(void);
 #endif
-- 
1.7.9.2



More information about the vlc-devel mailing list