Werner Lemberg wrote: > > Alternatively, you can also use the gnulib module 'localcharset', > > which does the same thing in a more portable way. I.e., it solves > > the portability problems to FreeBSD, NetBSD, OpenBSD, MacOS X, > > Solaris 7, Woe32, VMS and others. > > This is probably better, given that Keith and others have invested a > lot of time to make groff run with Win32. In case you have time: Can > you provide a patch?
Here is the patch. > Note that groff comes with a `relocate' implementation of its own > which has been inspired partly by gnulib's version. The different include file name (relocatable.h versus relocate.h) forced me to make a groff-local modification to the localcharset.c file coming from gnulib. Also I had to change the linkage of the relocatep() function, so that it can be called from C code. 2006-01-07 Bruno Haible <[EMAIL PROTECTED]> Work around unportability of nl_langinfo(CODESET). * m4/glibc21.m4: New file, from gnulib. * Makefile.sub (M4MACROS): Add m4/glibc21.m4. * configure.ac: Also test for stddef.h, and invoke jm_GLIBC21. * Makefile.in (HOST, GLIBC21): New variables. (MDEFINES): Pass them to subdirectories. * src/include/relocate.h (relocatep): Define with C linkage. * src/include/localcharset.h: New file, from gnulib. * src/libs/libgroff/localcharset.c: New file, from gnulib with a modification for relocate(). * src/libs/libgroff/config.charset: New file, from gnulib. * src/libs/libgroff/ref-add.sin: New file, from gnulib. * src/libs/libgroff/ref-del.sin: New file, from gnulib. * src/libs/libgroff/Makefile.sub (EXTRA_CFLAGS): Also define LIBDIR. (OBJS): Add localcharset.o. (CSRCS): Add localcharset.c. (all): Add dependencies to charset.alias, ref-add.sed, ref-del.sed. (charset.alias): New rule. (PACKAGE): New variable. (ref-add.sed, ref-del.sed): New rules. (MKINSTALLDIRS): New variable. (install_data): Depend on install_charset_data. (install_charset_data): New rule for creating or updating charset.alias. (uninstall_sub): Depend on uninstall_charset_data. (uninstall_charset_data): New rule for uninstalling or updating charset.alias. * src/preproc/preconv/preconv.cpp: Include localcharset.h instead of <langinfo.h>. (main): Initialize default_encoding from locale_charset() instead of nl_langinfo(CODESET). *** Makefile.sub.bak 2006-01-06 22:36:03.000000000 +0100 --- Makefile.sub 2006-01-07 22:11:22.000000000 +0100 *************** *** 14,20 **** M4MACROS = \ $(srcdir)/m4/groff.m4 \ ! $(srcdir)/m4/codeset.m4 \ $(srcdir)/m4/iconv.m4 \ $(srcdir)/m4/lib-link.m4 $(srcdir)/m4/lib-ld.m4 $(srcdir)/m4/lib-prefix.m4 --- 14,20 ---- M4MACROS = \ $(srcdir)/m4/groff.m4 \ ! $(srcdir)/m4/codeset.m4 $(srcdir)/m4/glibc21.m4 \ $(srcdir)/m4/iconv.m4 \ $(srcdir)/m4/lib-link.m4 $(srcdir)/m4/lib-ld.m4 $(srcdir)/m4/lib-prefix.m4 *** configure.ac.bak 2006-01-06 22:36:04.000000000 +0100 --- configure.ac 2006-01-07 22:21:52.000000000 +0100 *************** *** 1,5 **** # Autoconf configuration file for groff. ! # Copyright (C) 1989-1995, 2001, 2002, 2003, 2004, 2005 # Free Software Foundation, Inc. # # This file is part of groff. --- 1,5 ---- # Autoconf configuration file for groff. ! # Copyright (C) 1989-1995, 2001-2006 # Free Software Foundation, Inc. # # This file is part of groff. *************** *** 51,57 **** AC_SUBST([SH_SCRIPT_SED_CMD]) # checks for headers ! AC_CHECK_HEADERS([stdlib.h unistd.h dirent.h limits.h sys/dir.h \ string.h strings.h math.h sys/time.h direct.h process.h]) GROFF_ISC_SYSV3 GROFF_POSIX --- 51,57 ---- AC_SUBST([SH_SCRIPT_SED_CMD]) # checks for headers ! AC_CHECK_HEADERS([stddef.h stdlib.h unistd.h dirent.h limits.h sys/dir.h \ string.h strings.h math.h sys/time.h direct.h process.h]) GROFF_ISC_SYSV3 GROFF_POSIX *************** *** 121,126 **** --- 121,127 ---- GROFF_HTML_PROGRAMS GROFF_PDFDOC_PROGRAMS GROFF_PNMTOPS_NOSETPAGE + jm_GLIBC21 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h]) AC_CONFIG_FILES([Makefile doc/Makefile src/utils/xtotroff/Makefile]) *** Makefile.in.bak 2006-01-06 22:36:03.000000000 +0100 --- Makefile.in 2006-01-07 22:42:39.000000000 +0100 *************** *** 25,30 **** --- 25,36 ---- [EMAIL PROTECTED]@ [EMAIL PROTECTED]@ + # `HOST' is the canonical host specification, + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM + # or + # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM + [EMAIL PROTECTED]@ + # `RT_SEP' is the operating system's native PATH SEPARATOR CHAR, which # is to be used in runtime PATHs compiled into groff executables. [EMAIL PROTECTED]@ *************** *** 34,39 **** --- 40,49 ---- # particularly in some Microsoft environments, it may differ. [EMAIL PROTECTED]@ + # `GLIBC21' is yes if the host operating system uses GNU libc 2.1 or newer, + # otherwise no. + [EMAIL PROTECTED]@ + version=`cat $(top_srcdir)/VERSION` # No additional number if revision is zero. revision=`sed -e 's/^0$$//' -e 's/^[1-9].*$$/.&/' $(top_srcdir)/REVISION` *************** *** 420,425 **** --- 430,437 ---- "ETAGSCCFLAG=$(ETAGSCCFLAG)" \ "ETAGSFLAGS=$(ETAGSFLAGS)" \ "EXEEXT=$(EXEEXT)" \ + "GLIBC21=$(GLIBC21)" \ + "HOST=$(HOST)" \ "INSTALL_DATA=$(INSTALL_DATA)" \ "INSTALL_INFO=$(INSTALL_INFO)" \ "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \ *** src/include/relocate.h.bak 2005-07-07 13:16:42.000000000 +0200 --- src/include/relocate.h 2006-01-07 23:13:14.000000000 +0100 *************** *** 1,6 **** // -*- C++ -*- /* Provide relocation for macro and font files. ! Copyright (C) 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published --- 1,6 ---- // -*- C++ -*- /* Provide relocation for macro and font files. ! Copyright (C) 2005-2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published *************** *** 17,27 **** --- 17,38 ---- Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */ + #ifdef __cplusplus extern char *curr_prefix; extern size_t curr_prefix_len; void set_current_prefix (); char *xdirname (char *s); char *searchpath (const char *name, const char *pathp); + #endif + + /* This function has C linkage. */ + extern + #ifdef __cplusplus + "C" + #endif char *relocatep (const char *path); + + #ifdef __cplusplus char *relocate (const char *path); + #endif *** src/libs/libgroff/Makefile.sub.bak 2005-07-07 13:16:42.000000000 +0200 --- src/libs/libgroff/Makefile.sub 2006-01-07 23:05:11.000000000 +0100 *************** *** 1,5 **** LIB=groff ! EXTRA_CFLAGS=-D__GETOPT_PREFIX=groff_ OBJS=\ assert.$(OBJEXT) \ change_lf.$(OBJEXT) \ --- 1,5 ---- LIB=groff ! EXTRA_CFLAGS=-D__GETOPT_PREFIX=groff_ -DLIBDIR=\"$(libdir)\" OBJS=\ assert.$(OBJEXT) \ change_lf.$(OBJEXT) \ *************** *** 24,29 **** --- 24,30 ---- itoa.$(OBJEXT) \ lf.$(OBJEXT) \ lineno.$(OBJEXT) \ + localcharset.$(OBJEXT) \ macropath.$(OBJEXT) \ matherr.$(OBJEXT) \ maxfilename.$(OBJEXT) \ *************** *** 97,102 **** --- 98,104 ---- $(srcdir)/getopt1.c \ $(srcdir)/iftoa.c \ $(srcdir)/itoa.c \ + $(srcdir)/localcharset.c \ $(srcdir)/matherr.c \ $(srcdir)/progname.c \ $(srcdir)/putenv.c \ *************** *** 124,126 **** --- 126,179 ---- snprintf.$(OBJEXT): $(srcdir)/../snprintf/snprintf.c $(CC) -c $(CDEFINES) $(CFLAGS) $(CPPFLAGS) \ $(srcdir)/../snprintf/snprintf.c + + # Data for localcharset.c. Taken from libiconv/libcharset. + + all: charset.alias ref-add.sed ref-del.sed + + charset.alias: $(srcdir)/config.charset + $(SHELL) $(srcdir)/config.charset '$(HOST)' > t-$@ + mv t-$@ $@ + + PACKAGE=groff + + ref-add.sed : $(srcdir)/ref-add.sin + sed -e '/^#/d' -e 's/@''PACKAGE''@/$(PACKAGE)/g' $(srcdir)/ref-add.sin > t-$@ + mv t-$@ $@ + + ref-del.sed : $(srcdir)/ref-del.sin + sed -e '/^#/d' -e 's/@''PACKAGE''@/$(PACKAGE)/g' $(srcdir)/ref-del.sin > t-$@ + mv t-$@ $@ + + MKINSTALLDIRS = $(SHELL) $(top_srcdir)/mkinstalldirs + + install_data: install_charset_data + install_charset_data: + test $(GLIBC21) != no || $(MKINSTALLDIRS) $(DESTDIR)$(libdir) + if test -f $(DESTDIR)$(libdir)/charset.alias; then \ + sed -f ref-add.sed $(DESTDIR)$(libdir)/charset.alias > $(DESTDIR)$(libdir)/t-charset.alias; \ + $(INSTALL_DATA) $(DESTDIR)$(libdir)/t-charset.alias $(DESTDIR)$(libdir)/charset.alias; \ + rm -f $(DESTDIR)$(libdir)/t-charset.alias; \ + else \ + if test $(GLIBC21) = no; then \ + sed -f ref-add.sed charset.alias > $(DESTDIR)$(libdir)/t-charset.alias; \ + $(INSTALL_DATA) $(DESTDIR)$(libdir)/t-charset.alias $(DESTDIR)$(libdir)/charset.alias; \ + rm -f $(DESTDIR)$(libdir)/t-charset.alias; \ + fi; \ + fi + + uninstall_sub: uninstall_charset_data + uninstall_charset_data: + if test -f $(DESTDIR)$(libdir)/charset.alias; then \ + sed -f ref-del.sed $(DESTDIR)$(libdir)/charset.alias > $(DESTDIR)$(libdir)/t-charset.alias; \ + if grep '^# Packages using this file: $$' $(DESTDIR)$(libdir)/t-charset.alias > /dev/null; then \ + rm -f $(DESTDIR)$(libdir)/charset.alias; \ + else \ + $(INSTALL_DATA) $(DESTDIR)$(libdir)/t-charset.alias $(DESTDIR)$(libdir)/charset.alias; \ + fi; \ + rm -f $(DESTDIR)$(libdir)/t-charset.alias; \ + fi + + clean: clean_charset + clean_charset: + rm -f charset.alias ref-add.sed ref-del.sed *** src/preproc/preconv/preconv.cpp.bak 2006-01-06 22:36:04.000000000 +0100 --- src/preproc/preconv/preconv.cpp 2006-01-07 22:51:31.000000000 +0100 *************** *** 26,40 **** #include <errno.h> #include "errarg.h" #include "error.h" #include "nonposix.h" #include "stringclass.h" #include <locale.h> - #if HAVE_LANGINFO_CODESET - # include <langinfo.h> - #endif - #if HAVE_ICONV # include <iconv.h> # ifdef WORDS_BIGENDIAN --- 26,37 ---- #include <errno.h> #include "errarg.h" #include "error.h" + #include "localcharset.h" #include "nonposix.h" #include "stringclass.h" #include <locale.h> #if HAVE_ICONV # include <iconv.h> # ifdef WORDS_BIGENDIAN *************** *** 1102,1119 **** // getopt() is called since the usage message shows the default // encoding. setlocale(LC_ALL, ""); - #if HAVE_LANGINFO_CODESET char *locale = setlocale(LC_CTYPE, NULL); if (!locale || !strcmp(locale, "C") || !strcmp(locale, "POSIX")) default_encoding = "latin1"; ! else { ! default_encoding = nl_langinfo(CODESET); ! if (!default_encoding) ! default_encoding = "latin1"; ! } ! #else ! default_encoding = "latin1"; ! #endif /* HAVE_LANGINFO_CODESET */ program_name = argv[0]; int opt; --- 1099,1109 ---- // getopt() is called since the usage message shows the default // encoding. setlocale(LC_ALL, ""); char *locale = setlocale(LC_CTYPE, NULL); if (!locale || !strcmp(locale, "C") || !strcmp(locale, "POSIX")) default_encoding = "latin1"; ! else ! default_encoding = locale_charset(); program_name = argv[0]; int opt;
to-werner2.tgz
Description: localcharset-new-files.tar.gz
_______________________________________________ Groff mailing list Groff@gnu.org http://lists.gnu.org/mailman/listinfo/groff