[Rd] [patch] R-1.9.0: compile error without nl_langinfo(CODESET) (PR#6789)

bunk at fs.tum.de bunk at fs.tum.de
Sun Apr 18 00:19:01 CEST 2004


I got the following compile error in R-1.9.0 on NetBSD 1.5:
 
<--  snip  -->
 
...
gcc -I../../src/extra/zlib -I../../src/extra/bzip2
-I../../src/extra/pcre -I. -I../../src/include -I../../src/include -I/usr/local/include  
-DHAVE_CONFIG_H   -O2 -mcpu=v8 -c main.c -o main.o
main.c: In function `setup_Rmainloop':
main.c:463: `CODESET' undeclared (first use in this function)
main.c:463: (Each undeclared identifier is reported only once
main.c:463: for each function it appears in.)
make[3]: *** [main.o] Error 1
make[3]: Leaving directory `/aux/adrian/build/R-1.9.0/src/main'
 
<--  snip  -->
 
NetBSD 1.5 has a nl_langinfo() in langinfo.h but no CODESET.
 
A proposed patch (based on codeset.m4 from GNU gettext) is below.
 
cu
Adrian


 
--- /dev/null	2004-04-17 15:10:09 +0200
+++ m4/codeset.m4	2004-04-17 15:15:31 +0200
@@ -0,0 +1,23 @@
+# codeset.m4 serial AM1 (gettext-0.10.40)
+dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License.  As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+dnl From Bruno Haible.
+
+AC_DEFUN([AM_LANGINFO_CODESET],
+[
+  AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
+    [AC_TRY_LINK([#include <langinfo.h>],
+      [char* cs = nl_langinfo(CODESET);],
+      am_cv_langinfo_codeset=yes,
+      am_cv_langinfo_codeset=no)
+    ])
+  if test $am_cv_langinfo_codeset = yes; then
+    AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
+      [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
+  fi
+])
--- m4/README.old	2004-04-17 15:16:01 +0200
+++ m4/README	2004-04-17 15:18:27 +0200
@@ -38,3 +38,7 @@
 
   libtool.m4
 	is from libtool 1.5.
+
+  codeset.m4
+	is from GNU gettext and checks whether nl_langinfo(CODESET)
+	is available in langinfo.h.
--- configure.ac.old	2004-04-17 12:41:22 +0200
+++ configure.ac	2004-04-17 15:21:51 +0200
@@ -510,7 +510,7 @@
 ## Some of these are also checked for when Autoconf computes the default
 ## includes.
 AC_CHECK_HEADERS(arpa/inet.h dl.h dlfcn.h elf.h fcntl.h floatingpoint.h \
-  fpu_control.h grp.h ieee754.h ieeefp.h langinfo.h locale.h \
+  fpu_control.h grp.h ieee754.h ieeefp.h locale.h \
   netdb.h netinet/in.h \
   pwd.h readline/history.h readline/readline.h strings.h \
   sys/param.h sys/select.h sys/socket.h sys/stat.h sys/time.h \
@@ -1161,13 +1161,17 @@
 AC_FUNC_ALLOCA
 AC_CHECK_FUNCS(access chdir expm1 fcntl finite ftruncate getcwd \
   getgrgid getpwuid getuid hypot isascii isnan log1p matherr mkfifo \
-  nl_langinfo popen putenv rint setenv strcoll stat strptime symlink \
+  popen putenv rint setenv strcoll stat strptime symlink \
   system times unsetenv)
 ## <NOTE>
 ## No need checking for bcopy bzero memcpy mempcpy even though ifnames
 ## might report corresponding HAVE_FOO conditionals.
 ## </NOTE>
 
+## check whether nl_langinfo(CODESET) is in langinfo.h
+## defines HAVE_LANGINFO_CODESET if it's there
+AM_LANGINFO_CODESET
+
 ## Used to build src/include/Rmath.h.
 ## <NOTE>
 ## we don't use AC_CONFIG_HEADERS on Rmath.h.in because
--- src/main/main.c.old	2004-04-17 15:03:50 +0200
+++ src/main/main.c	2004-04-17 15:22:37 +0200
@@ -37,7 +37,7 @@
 # include <locale.h>
 #endif
 
-#ifdef HAVE_LANGINFO_H
+#ifdef HAVE_LANGINFO_CODESET
 # include <langinfo.h>
 #endif
 
@@ -459,7 +459,7 @@
 		RSetConsoleWidth();
 	}
 #endif
-#ifdef HAVE_NL_LANGINFO
+#ifdef HAVE_LANGINFO_CODESET
     utf8locale = strcmp(nl_langinfo(CODESET), "UTF-8") == 0;
 #endif
     /* gc_inhibit_torture = 0; */
--- src/main/platform.c.old	2004-04-17 15:06:04 +0200
+++ src/main/platform.c	2004-04-17 15:22:54 +0200
@@ -886,7 +886,7 @@
 #ifdef HAVE_LOCALE_H
 # include <locale.h>
 #endif
-#ifdef HAVE_LANGINFO_H
+#ifdef HAVE_LANGINFO_CODESET
 # include <langinfo.h>
 #endif
 
@@ -914,7 +914,7 @@
     if(p) SET_STRING_ELT(ans, 0, mkChar(p));
     else  SET_STRING_ELT(ans, 0, mkChar(""));
     UNPROTECT(1);
-#ifdef HAVE_NL_LANGINFO
+#ifdef HAVE_LANGINFO_CODESET
     utf8locale = strcmp(nl_langinfo(CODESET), "UTF-8") == 0;
 #endif    
     return ans;
--- m4/Makefile.in.old	2004-04-17 15:27:37 +0200
+++ m4/Makefile.in	2004-04-17 15:27:50 +0200
@@ -13,6 +13,7 @@
 distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
 DISTFILES = Makefile.in README \
 	R.m4 \
+	codeset.m4 \
 	gnome-gnorba-check.m4 \
 	gnome-orbit-check.m4 \
 	gnome.m4 \



More information about the R-devel mailing list