[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gettext.h patch for portability to sunCC, pgCC, RHEL AS 4 g++
From: |
Paul Eggert |
Subject: |
gettext.h patch for portability to sunCC, pgCC, RHEL AS 4 g++ |
Date: |
Tue, 24 Oct 2006 17:23:20 -0700 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) |
address@hidden (Karl Berry) writes:
> Is supporting compilation with C++ of interest?
Not in general. Coreutils, for example, generates about 400 lines worth
of diagnostics when compiled using g++ 4.1.1. This explains the quotearg
problems you mentioned: quotearg doesn't attempt to be portable to C++.
However, gettext.h does attempt to be portable to C++, so the problems
you found there suggest that a fix is needed. It currently does this:
#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
(__GNUC__ >= 3 || defined __cplusplus)
but (as you've found) older C++ compilers define __cplusplus without
having variable-length arrays. Also, many C compilers other than GCC
have variable length arrays, and don't need to be penalized.
Bruno, how about this patch?
2006-10-24 Paul Eggert <address@hidden>
* lib/gettext.h (_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS): Remove.
All uses replaced by HAVE_C_VARARRAYS.
* modules/gettext-h: Depend on vararrays.
Index: lib/gettext.h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/gettext.h,v
retrieving revision 1.8
diff -c -r1.8 gettext.h
*** lib/gettext.h 17 Oct 2006 12:50:48 -0000 1.8
--- lib/gettext.h 24 Oct 2006 23:00:27 -0000
***************
*** 163,172 ****
#include <string.h>
! #define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
! (__GNUC__ >= 3 || defined __cplusplus)
!
! #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
#include <stdlib.h>
#endif
--- 163,169 ----
#include <string.h>
! #if !HAVE_C_VARARRAYS
#include <stdlib.h>
#endif
***************
*** 190,196 ****
size_t msgctxt_len = strlen (msgctxt) + 1;
size_t msgid_len = strlen (msgid) + 1;
const char *translation;
! #if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
char msg_ctxt_id[msgctxt_len + msgid_len];
#else
char buf[1024];
--- 187,193 ----
size_t msgctxt_len = strlen (msgctxt) + 1;
size_t msgid_len = strlen (msgid) + 1;
const char *translation;
! #if HAVE_C_VARARRAYS
char msg_ctxt_id[msgctxt_len + msgid_len];
#else
char buf[1024];
***************
*** 205,211 ****
msg_ctxt_id[msgctxt_len - 1] = '\004';
memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
translation = dcgettext (domain, msg_ctxt_id, category);
! #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
if (msg_ctxt_id != buf)
free (msg_ctxt_id);
#endif
--- 202,208 ----
msg_ctxt_id[msgctxt_len - 1] = '\004';
memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
translation = dcgettext (domain, msg_ctxt_id, category);
! #if !HAVE_C_VARARRAYS
if (msg_ctxt_id != buf)
free (msg_ctxt_id);
#endif
***************
*** 236,242 ****
size_t msgctxt_len = strlen (msgctxt) + 1;
size_t msgid_len = strlen (msgid) + 1;
const char *translation;
! #if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
char msg_ctxt_id[msgctxt_len + msgid_len];
#else
char buf[1024];
--- 233,239 ----
size_t msgctxt_len = strlen (msgctxt) + 1;
size_t msgid_len = strlen (msgid) + 1;
const char *translation;
! #if HAVE_C_VARARRAYS
char msg_ctxt_id[msgctxt_len + msgid_len];
#else
char buf[1024];
***************
*** 251,257 ****
msg_ctxt_id[msgctxt_len - 1] = '\004';
memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n,
category);
! #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
if (msg_ctxt_id != buf)
free (msg_ctxt_id);
#endif
--- 248,254 ----
msg_ctxt_id[msgctxt_len - 1] = '\004';
memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n,
category);
! #if !HAVE_C_VARARRAYS
if (msg_ctxt_id != buf)
free (msg_ctxt_id);
#endif
Index: modules/gettext-h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/gettext-h,v
retrieving revision 1.1
diff -c -r1.1 gettext-h
*** modules/gettext-h 6 Jul 2005 15:58:47 -0000 1.1
--- modules/gettext-h 24 Oct 2006 23:00:27 -0000
***************
*** 5,10 ****
--- 5,11 ----
lib/gettext.h
Depends-on:
+ vararrays
configure.ac:
- C++ support?, Karl Berry, 2006/10/24
- gettext.h patch for portability to sunCC, pgCC, RHEL AS 4 g++,
Paul Eggert <=
- Re: gettext.h patch for portability to sunCC, pgCC, RHEL AS 4 g++, Bruno Haible, 2006/10/25
- Re: gettext.h patch for portability to sunCC, pgCC, RHEL AS 4 g++, Paul Eggert, 2006/10/25
- Re: gettext.h patch for portability to sunCC, pgCC, RHEL AS 4 g++, Bruno Haible, 2006/10/25
Re: C++ support?, Bob Proulx, 2006/10/25
Re: [bug-gnulib] C++ support?, Bruno Haible, 2006/10/25