From 2d4f4c890aadbdfb310b5cf1dd1551c5543f1533 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 8 Aug 2001 12:55:08 +0000 Subject: [PATCH] Make it possible to build with CC=gcc CFLAGS="-x c++". --- ChangeLog | 18 ++++++++++++++++++ lib/Makefile.in | 6 +++--- lib/loop_wchar.h | 10 +++++----- libcharset/lib/ChangeLog | 6 ++++++ libcharset/lib/localcharset.c | 9 +++++++-- src/Makefile.in | 9 ++++++--- tests/Makefile.in | 16 +++++++++++----- 7 files changed, 56 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1bf3fb2..667f4dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2001-08-05 Bruno Haible + + Make it possible to build libiconv with CC=gcc CFLAGS="-x c++". + * lib/loop_wchar.h (wchar_to_loop_convert): Rename local variable + 'try' to 'incount'. + * lib/Makefile.in (libiconv_plug_linux.so): Add "-x none" option + between sources and libs. + (libiconv_plug_solaris.so) [GCC]: Likewise. + (libiconv_plug_osf.so) [GCC]: Likewise. + * src/Makefile.in (iconv.@OBJEXT@): New rule. + (iconv): Depend on it. + (clean): Erase *.@OBJEXT@, not *.o. + * tests/Makefile.in (table-from.@OBJEXT@): New rule. + (table-from): Depend on it. + (table-to.@OBJEXT@): New rule. + (table-to): Depend on it. + (clean): Erase *.@OBJEXT@, not *.o. + 2001-07-28 Bruno Haible * tools/Makefile (iso8859_16.h): Generate from the unicode.org table. diff --git a/lib/Makefile.in b/lib/Makefile.in index 9804aa8..863d785 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -60,18 +60,18 @@ libiconv_plug.so : libiconv_plug_@OS@.so $(LN_S) libiconv_plug_@OS@.so libiconv_plug.so libiconv_plug_linux.so : $(SOURCES) - $(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS) -fPIC -DPIC -DLIBICONV_PLUG $(SOURCES) $(LIBCHARSET_OBJECTS) -shared -o libiconv_plug_linux.so + $(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS) -fPIC -DPIC -DLIBICONV_PLUG $(SOURCES) -x none $(LIBCHARSET_OBJECTS) -shared -o libiconv_plug_linux.so libiconv_plug_solaris.so : $(SOURCES) if test -n "@GCC@"; then \ - $(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS) -fPIC -DPIC -DLIBICONV_PLUG $(SOURCES) $(LIBCHARSET_OBJECTS) -G -o libiconv_plug_solaris.so; \ + $(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS) -fPIC -DPIC -DLIBICONV_PLUG $(SOURCES) -x none $(LIBCHARSET_OBJECTS) -G -o libiconv_plug_solaris.so; \ else \ $(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS) -KPIC -DPIC -DLIBICONV_PLUG $(SOURCES) $(LIBCHARSET_OBJECTS) -G -o libiconv_plug_solaris.so; \ fi libiconv_plug_osf.so : $(SOURCES) if test -n "@GCC@"; then \ - $(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS) -fPIC -DPIC -DLIBICONV_PLUG $(SOURCES) $(LIBCHARSET_OBJECTS) -shared -o libiconv_plug_osf.so; \ + $(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS) -fPIC -DPIC -DLIBICONV_PLUG $(SOURCES) -x none $(LIBCHARSET_OBJECTS) -shared -o libiconv_plug_osf.so; \ else \ $(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS) -DPIC -DLIBICONV_PLUG $(SOURCES) $(LIBCHARSET_OBJECTS) -c -o iconv_plug.o; \ /bin/ld -shared -expect_unresolved \* -o libiconv_plug_osf.so iconv_plug.o; \ diff --git a/lib/loop_wchar.h b/lib/loop_wchar.h index 1607579..27d912a 100644 --- a/lib/loop_wchar.h +++ b/lib/loop_wchar.h @@ -181,11 +181,11 @@ static size_t wchar_to_loop_convert (iconv_t icd, struct wchar_conv_struct * wcd = (struct wchar_conv_struct *) icd; size_t result = 0; while (*inbytesleft > 0) { - size_t try; - for (try = 1; try <= *inbytesleft; try++) { + size_t incount; + for (incount = 1; incount <= *inbytesleft; incount++) { char buf[BUF_SIZE]; const char* inptr = *inbuf; - size_t inleft = try; + size_t inleft = incount; char* bufptr = buf; size_t bufleft = BUF_SIZE; size_t res = unicode_loop_convert(&wcd->parent, @@ -219,8 +219,8 @@ static size_t wchar_to_loop_convert (iconv_t icd, *(wchar_t*) *outbuf = wc; *outbuf += sizeof(wchar_t); *outbytesleft -= sizeof(wchar_t); - *inbuf += try; - *inbytesleft -= try; + *inbuf += incount; + *inbytesleft -= incount; result += res; break; } diff --git a/libcharset/lib/ChangeLog b/libcharset/lib/ChangeLog index 5eb2b57..93d1b3d 100644 --- a/libcharset/lib/ChangeLog +++ b/libcharset/lib/ChangeLog @@ -1,3 +1,9 @@ +2001-08-05 Bruno Haible + + Make it possible to build libcharset with CC=gcc CFLAGS="-x c++". + * localcharset.c (locale_charset): Declare as extern "C". + (get_charset_aliases): Cast malloc and realloc results to 'char *'. + 2001-06-27 Bruno Haible * Makefile.in (clean): Remove also *.o.lock, left there by libtool diff --git a/libcharset/lib/localcharset.c b/libcharset/lib/localcharset.c index 61f8f3e..583cdd1 100644 --- a/libcharset/lib/localcharset.c +++ b/libcharset/lib/localcharset.c @@ -63,6 +63,11 @@ # define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR) #endif +#ifdef __cplusplus +/* When compiling with "gcc -x c++", produce a function with C linkage. */ +extern "C" const char * locale_charset (void); +#endif + /* The following static variable is declared 'volatile' to avoid a possible multithread problem in the function get_charset_aliases. If we are running in a threaded environment, and if two threads initialize @@ -145,12 +150,12 @@ get_charset_aliases () if (res_size == 0) { res_size = l1 + 1 + l2 + 1; - res_ptr = malloc (res_size + 1); + res_ptr = (char *) malloc (res_size + 1); } else { res_size += l1 + 1 + l2 + 1; - res_ptr = realloc (res_ptr, res_size + 1); + res_ptr = (char *) realloc (res_ptr, res_size + 1); } if (res_ptr == NULL) { diff --git a/src/Makefile.in b/src/Makefile.in index c4e939b..27a85df 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -39,8 +39,11 @@ top_builddir = .. all : iconv -iconv : $(srcdir)/iconv.c ../lib/libiconv.la - $(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(INCLUDES) -I../lib $(CFLAGS) $(CPPFLAGS) $(srcdir)/iconv.c ../lib/libiconv.la -o $@ +iconv : iconv.@OBJEXT@ ../lib/libiconv.la + $(LIBTOOL_LINK) $(CC) $(LDFLAGS) iconv.@OBJEXT@ ../lib/libiconv.la -o $@ + +iconv.@OBJEXT@ : $(srcdir)/iconv.c + $(CC) -c $(INCLUDES) -I../lib $(CFLAGS) $(CPPFLAGS) $(srcdir)/iconv.c # The following rule is necessary to avoid a toplevel "make -n check" failure. ../lib/libiconv.la : @@ -65,7 +68,7 @@ check : all mostlyclean : clean clean : force - $(RM) *.o *.lo iconv core + $(RM) *.@OBJEXT@ *.lo iconv core $(RM) -r .libs _libs distclean : clean diff --git a/tests/Makefile.in b/tests/Makefile.in index c662fa9..7770d09 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -136,11 +136,17 @@ check : all table-from table-to ../src/iconv $(srcdir)/check-translit $(srcdir) Quotes UTF-8 ISO-8859-1 $(srcdir)/check-translit $(srcdir) Quotes UTF-8 ASCII -table-from : $(srcdir)/table-from.c ../lib/libiconv.la - $(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS) $(srcdir)/table-from.c ../lib/libiconv.la -o $@ +table-from : table-from.@OBJEXT@ ../lib/libiconv.la + $(LIBTOOL_LINK) $(CC) $(LDFLAGS) table-from.@OBJEXT@ ../lib/libiconv.la -o $@ -table-to : $(srcdir)/table-to.c ../lib/libiconv.la - $(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS) $(srcdir)/table-to.c ../lib/libiconv.la -o $@ +table-from.@OBJEXT@ : $(srcdir)/table-from.c + $(CC) -c $(INCLUDES) $(CFLAGS) $(CPPFLAGS) $(srcdir)/table-from.c + +table-to : table-to.@OBJEXT@ ../lib/libiconv.la + $(LIBTOOL_LINK) $(CC) $(LDFLAGS) table-to.@OBJEXT@ ../lib/libiconv.la -o $@ + +table-to.@OBJEXT@ : $(srcdir)/table-to.c + $(CC) -c $(INCLUDES) $(CFLAGS) $(CPPFLAGS) $(srcdir)/table-to.c # The following rule is necessary to avoid a toplevel "make -n check" failure. ../lib/libiconv.la : @@ -149,7 +155,7 @@ table-to : $(srcdir)/table-to.c ../lib/libiconv.la mostlyclean : clean clean : force - $(RM) *.o *.lo table-from table-to tmp-* genutf8 UTF-8.TXT core + $(RM) *.@OBJEXT@ *.lo table-from table-to tmp-* genutf8 UTF-8.TXT core $(RM) -r .libs _libs distclean : clean -- 2.11.4.GIT