[Patch] correctly configure wcwidth in readline

Kris Warkentin
2003-02-26T16:47:06Z

[-- Attachment #1: Type: text/plain, Size: 785 bytes --]

I have attached a patch that correctly deals with the absence of a wcwidth()
function by building support/wcwidth.c and linking it into libreadline.
Oddly enough, the HAVE_WCWIDTH check fails on other systems too (ie. Cygwin)
but causes no problem since wcwidth() gets picked up elsewhere. On QNX
Neutrino, however, we're actually missing wcwidth() so we get undefined
references. What is the procedure for regenerating configure scripts?
Should I regenerate it here and commit it or do you have a certain person
who does it under a specific environment?

cheers,

Kris

Changelog

* aclocal.m4: Cause wcwidth check to substitute HAVE_WCWIDTH for
building.
* Makefile.in: Add wcwidth object to lib if required.
* shlib/Makefile.in: Likewise.
* configure: Regenerate.

[-- Attachment #2: readline_diff.txt --]
[-- Type: text/plain, Size: 6430 bytes --]

Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/readline/Makefile.in,v
retrieving revision 1.4
diff -c -r1.4 Makefile.in
*** Makefile.in 8 Dec 2002 22:31:37 -0000 1.4
--- Makefile.in 26 Feb 2003 16:36:15 -0000
***************
*** 86,91 ****
--- 86,98 ----
LIBRARY_NAME = libreadline.a
STATIC_LIBS = libreadline.a libhistory.a

+ HAVE_WCWIDTH = @HAVE_WCWIDTH@
+
+ ifeq ($(HAVE_WCWIDTH), no)
+ WCWIDTH_SRC = $(srcdir)/support/wcwidth.c
+ WCWIDTH_OBJ = wcwidth.o
+ endif
+
# The C code source files for this library.
CSOURCES = $(srcdir)/readline.c $(srcdir)/funmap.c $(srcdir)/keymaps.c \
$(srcdir)/vi_mode.c $(srcdir)/parens.c $(srcdir)/rltty.c \
***************
*** 98,104 ****
$(srcdir)/histfile.c $(srcdir)/nls.c $(srcdir)/search.c \
$(srcdir)/shell.c $(srcdir)/savestring.c $(srcdir)/tilde.c \
$(srcdir)/text.c $(srcdir)/misc.c $(srcdir)/compat.c \
! $(srcdir)/mbutil.c

# The header files for this library.
HSOURCES = readline.h rldefs.h chardefs.h keymaps.h history.h histlib.h \
--- 105,111 ----
$(srcdir)/histfile.c $(srcdir)/nls.c $(srcdir)/search.c \
$(srcdir)/shell.c $(srcdir)/savestring.c $(srcdir)/tilde.c \
$(srcdir)/text.c $(srcdir)/misc.c $(srcdir)/compat.c \
! $(srcdir)/mbutil.c $(WCWIDTH_SRC)

# The header files for this library.
HSOURCES = readline.h rldefs.h chardefs.h keymaps.h history.h histlib.h \
***************
*** 111,117 ****
OBJECTS = readline.o vi_mode.o funmap.o keymaps.o parens.o search.o \
rltty.o complete.o bind.o isearch.o display.o signals.o \
util.o kill.o undo.o macro.o input.o callback.o terminal.o \
! text.o nls.o misc.o compat.o xmalloc.o $(HISTOBJ) $(TILDEOBJ)

# The texinfo files which document this library.
DOCSOURCE = doc/rlman.texinfo doc/rltech.texinfo doc/rluser.texinfo
--- 118,125 ----
OBJECTS = readline.o vi_mode.o funmap.o keymaps.o parens.o search.o \
rltty.o complete.o bind.o isearch.o display.o signals.o \
util.o kill.o undo.o macro.o input.o callback.o terminal.o \
! text.o nls.o misc.o compat.o xmalloc.o $(HISTOBJ) $(TILDEOBJ) \
! $(WCWIDTH_OBJ)

# The texinfo files which document this library.
DOCSOURCE = doc/rlman.texinfo doc/rltech.texinfo doc/rluser.texinfo
***************
*** 146,151 ****
--- 154,165 ----
$(RM) $@
$(AR) $(ARFLAGS) $@ $(HISTOBJ) xmalloc.o
-test -n "$(RANLIB)" && $(RANLIB) $@
+
+ ifeq ($(HAVE_WCWIDTH), no)
+ $(WCWIDTH_OBJ): $(WCWIDTH_SRC)
+ $(RM) $@
+ $(CC) $(CCFLAGS) -c $(WCWIDTH_SRC)
+ endif

# Since tilde.c is shared between readline and bash, make sure we compile
# it with the right flags when it's built as part of readline
Index: aclocal.m4
===================================================================
RCS file: /cvs/src/src/readline/aclocal.m4,v
retrieving revision 1.4
diff -c -r1.4 aclocal.m4
*** aclocal.m4 8 Dec 2002 22:31:37 -0000 1.4
--- aclocal.m4 26 Feb 2003 16:36:15 -0000
***************
*** 1653,1659 ****
AC_CHECK_HEADERS(langinfo.h)

AC_CHECK_FUNC(mbsrtowcs, AC_DEFINE(HAVE_MBSRTOWCS))
! AC_CHECK_FUNC(wcwidth, AC_DEFINE(HAVE_WCWIDTH))

AC_CACHE_CHECK([for mbstate_t], bash_cv_have_mbstate_t,
[AC_TRY_RUN([
--- 1653,1659 ----
AC_CHECK_HEADERS(langinfo.h)

AC_CHECK_FUNC(mbsrtowcs, AC_DEFINE(HAVE_MBSRTOWCS))
! AC_CHECK_FUNC(wcwidth, AC_DEFINE(HAVE_WCWIDTH), AC_SUBST(HAVE_WCWIDTH,no))

AC_CACHE_CHECK([for mbstate_t], bash_cv_have_mbstate_t,
[AC_TRY_RUN([
Index: shlib/Makefile.in
===================================================================
RCS file: /cvs/src/src/readline/shlib/Makefile.in,v
retrieving revision 1.4
diff -c -r1.4 Makefile.in
*** shlib/Makefile.in 8 Dec 2002 22:31:38 -0000 1.4
--- shlib/Makefile.in 26 Feb 2003 16:36:15 -0000
***************
*** 103,108 ****
--- 103,115 ----
SHARED_HISTORY = libhistory.$(SHLIB_LIBVERSION)
SHARED_LIBS = $(SHARED_READLINE) $(SHARED_HISTORY)

+ HAVE_WCWIDTH = @HAVE_WCWIDTH@
+
+ ifeq ($(HAVE_WCWIDTH), no)
+ WCWIDTH_SRC = $(srcdir)/support/wcwidth.c
+ WCWIDTH_OBJ = wcwidth.so
+ endif
+
# The C code source files for this library.
CSOURCES = $(topdir)/readline.c $(topdir)/funmap.c $(topdir)/keymaps.c \
$(topdir)/vi_mode.c $(topdir)/parens.c $(topdir)/rltty.c \
***************
*** 115,121 ****
$(topdir)/histfile.c $(topdir)/nls.c $(topdir)/search.c \
$(topdir)/shell.c $(topdir)/savestring.c $(topdir)/tilde.c \
$(topdir)/text.c $(topdir)/misc.c $(topdir)/compat.c \
! $(topdir)/mbutil.c

# The header files for this library.
HSOURCES = readline.h rldefs.h chardefs.h keymaps.h history.h histlib.h \
--- 122,128 ----
$(topdir)/histfile.c $(topdir)/nls.c $(topdir)/search.c \
$(topdir)/shell.c $(topdir)/savestring.c $(topdir)/tilde.c \
$(topdir)/text.c $(topdir)/misc.c $(topdir)/compat.c \
! $(topdir)/mbutil.c $(WCWIDTH_SRC)

# The header files for this library.
HSOURCES = readline.h rldefs.h chardefs.h keymaps.h history.h histlib.h \
***************
*** 129,135 ****
rltty.so complete.so bind.so isearch.so display.so signals.so \
util.so kill.so undo.so macro.so input.so callback.so terminal.so \
text.so nls.so misc.so xmalloc.so $(SHARED_HISTOBJ) $(SHARED_TILDEOBJ) \
! compat.so

##########################################################################

--- 136,142 ----
rltty.so complete.so bind.so isearch.so display.so signals.so \
util.so kill.so undo.so macro.so input.so callback.so terminal.so \
text.so nls.so misc.so xmalloc.so $(SHARED_HISTOBJ) $(SHARED_TILDEOBJ) \
! compat.so $(WCWIDTH_OBJ)

##########################################################################

***************
*** 152,157 ****
--- 159,171 ----
$(SHARED_HISTORY): $(SHARED_HISTOBJ) xmalloc.so
$(RM) $@
$(SHOBJ_LD) ${SHOBJ_LDFLAGS} ${SHLIB_XLDFLAGS} -o $@ $(SHARED_HISTOBJ) xmalloc.so $(SHLIB_LIBS)
+
+ ifeq ($(HAVE_WCWIDTH), no)
+ $(WCWIDTH_OBJ): $(WCWIDTH_SRC)
+ $(RM) $@
+ $(SHOBJ_CC) -c $(CCFLAGS) $(SHOBJ_FLAGS) -o wcwidth.o $(WCWIDTH_SRC)
+ $(MV) wcwidth.o $@
+ endif

# Since tilde.c is shared between readline and bash, make sure we compile
# it with the right flags when it's built as part of readline