shl_load (old HP-UX) loadable support

2009-02-24 Thread wooledg
Configuration Information [Automatically generated, do not change]:
Machine: hppa2.0
OS: hpux10.20
Compiler: /net/appl/gcc-3.3/bin/gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='hppa2.0' 
-DCONF_OSTYPE='hpux10.20' -DCONF_MACHTYPE='hppa2.0-hp-hpux10.20' 
-DCONF_VENDOR='hp' -DLOCALEDIR='/usr/local/share/locale' -DPACKAGE='bash' 
-DSHELL -DHAVE_CONFIG_H -DHPUX   -I.  -I. -I./include -I./lib -I./lib/intl 
-I/var/tmp/bash-4.0/lib/intl  -g -O2
uname output: HP-UX imadev B.10.20 A 9000/785 2008897791 two-user license
Machine Type: hppa2.0-hp-hpux10.20

Bash Version: 4.0
Patch Level: 0
Release Status: release

Description:
A patch to add support for the shl_load() family of functions.  Built against
bash 4.0 but it would probably work with older versions; the enable.def
code looks pretty much the same, I think.

Repeat-By:
(See patch.)

Fix:
This patch adds shl_load (old HP-UX) support to bash 4.0 for enabling
loadable builtins.  In order for bash on HP-UX to actually load most of
the builtins, it must be linked with the linker's -E flag as well, so
you'll need to do something like this:

 .../bash-4.0$ patch -p1 < ../bash-4.0-shl.diff
 .../bash-4.0$ autoconf
 .../bash-4.0$ CC=gcc LDFLAGS=-Wl,-E ./configure
 .../bash-4.0$ make

If you're using the native HP-UX compiler, then the options may differ.

--- bash-4.0/config.h.inSun Feb  1 17:07:23 2009
+++ bash-4.0-shl/config.h.inTue Feb 24 08:57:52 2009
@@ -537,6 +537,15 @@
 /* Define if you have the dlsym function.  */
 #undef HAVE_DLSYM
 
+/* Define if you have the shl_load function. */
+#undef HAVE_SHL_LOAD
+
+/* Define if you have the shl_unload function. */
+#undef HAVE_SHL_UNLOAD
+
+/* Define if you have the shl_findsym function. */
+#undef HAVE_SHL_FINDSYM
+
 /* Define if you don't have vprintf but do have _doprnt.  */
 #undef HAVE_DOPRNT
 
@@ -853,6 +862,9 @@
 
 /* Define if you have the  header file.  */
 #undef HAVE_DIRENT_H
+
+/* Define if you have the  header file.  */
+#undef HAVE_DL_H
 
 /* Define if you have the  header file.  */
 #undef HAVE_DLFCN_H
--- bash-4.0/configure.in   Fri Feb  6 12:03:44 2009
+++ bash-4.0-shl/configure.in   Tue Feb 24 08:58:49 2009
@@ -650,7 +650,7 @@
 BASH_HEADER_INTTYPES
 
 AC_CHECK_HEADERS(unistd.h stdlib.h stdarg.h varargs.h limits.h string.h \
-memory.h locale.h termcap.h termio.h termios.h dlfcn.h \
+memory.h locale.h termcap.h termio.h termios.h dl.h dlfcn.h \
 stddef.h stdint.h netdb.h pwd.h grp.h strings.h regex.h)
 AC_CHECK_HEADERS(sys/pte.h sys/stream.h sys/select.h sys/file.h \
 sys/resource.h sys/param.h sys/socket.h sys/stat.h \
@@ -798,6 +798,8 @@
 if test "$opt_static_link" != yes; then
 AC_CHECK_LIB(dl, dlopen)
 AC_CHECK_FUNCS(dlopen dlclose dlsym)
+AC_CHECK_LIB(dld, shl_load)
+AC_CHECK_FUNCS(shl_load shl_unload shl_findsym)
 fi
 
 dnl this defines HAVE_DECL_SYS_SIGLIST
@@ -1062,7 +1064,8 @@
 # Shared object configuration section.  These values are generated by
 # ${srcdir}/support/shobj-conf
 #
-if test "$ac_cv_func_dlopen" = "yes" && test -f ${srcdir}/support/shobj-conf
+if ( test "$ac_cv_func_dlopen" = "yes" || test "$ac_cv_func_shl_load" = "yes" 
)\
+  && test -f ${srcdir}/support/shobj-conf
 then
AC_MSG_CHECKING(shared object configuration for loadable builtins)
eval `${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C "${CC}" 
-c "${host_cpu}" -o "${host_os}" -v "${host_vendor}"`
--- bash-4.0/builtins/enable.defSun Jan  4 14:32:22 2009
+++ bash-4.0-shl/builtins/enable.defTue Feb 24 12:39:24 2009
@@ -82,11 +82,11 @@
 #define PFLAG  0x10
 #define SFLAG  0x20
 
-#if defined (HAVE_DLOPEN) && defined (HAVE_DLSYM)
+#if (defined (HAVE_DLOPEN) && defined (HAVE_DLSYM)) || (defined 
(HAVE_SHL_LOAD) && defined (HAVE_SHL_FINDSYM))
 static int dyn_load_builtin __P((WORD_LIST *, int, char *));
 #endif
 
-#if defined (HAVE_DLCLOSE)
+#if defined (HAVE_DLCLOSE) || defined (HAVE_SHL_UNLOAD)
 static int dyn_unload_builtin __P((char *));
 static void delete_builtin __P((struct builtin *));
 static int local_dlclose __P((void *));
@@ -104,7 +104,7 @@
 {
   int result, flags;
   int opt, filter;
-#if defined (HAVE_DLOPEN) && defined (HAVE_DLSYM)
+#if (defined (HAVE_DLOPEN) && defined (HAVE_DLSYM)) || (defined 
(HAVE_SHL_LOAD) && defined (HAVE_SHL_FINDSYM))
   char *filename;
 #endif
 
@@ -129,7 +129,7 @@
  flags |= SFLAG;
  break;
case 'f':
-#if defined (HAVE_DLOPEN) && defined (HAVE_DLSYM)
+#if (defined (HAVE_DLOPEN) && defined (HAVE_DLSYM)) || (defined 
(HAVE_SHL_LOAD) && defined (HAVE_SHL_FINDSYM))
  flags |= FFLAG;
  filename = list_optarg;
  break;
@@ -137,7 +137,7 @@
  builtin_error (_("dynamic loading not available"));
  return (EX_USAGE);
 #endif
-#if defined (HAVE_DLCLOSE)
+#if defined (HAVE_DLCLOSE) || defined (HAVE_SHL_UNLOAD)
case 'd':
  flags |= DFLAG;
  break;
@@ -172,7 +172,7 @@
 
   list_some_built

str1 < str2 does not respect locale

2009-04-08 Thread wooledg
Configuration Information [Automatically generated, do not change]:
Machine: hppa2.0
OS: hpux10.20
Compiler: /net/appl/gcc-3.3/bin/gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='hppa2.0' 
-DCONF_OSTYPE='hpux10.20' -DCONF_MACHTYPE='hppa2.0-hp-hpux10.20' 
-DCONF_VENDOR='hp' -DLOCALEDIR='/usr/local/share/locale' -DPACKAGE='bash' 
-DSHELL -DHAVE_CONFIG_H -DHPUX   -I.  -I. -I./include -I./lib -I./lib/intl 
-I/var/tmp/bash-4.0/lib/intl  -g -O2
uname output: HP-UX imadev B.10.20 A 9000/785 2008897791 two-user license
Machine Type: hppa2.0-hp-hpux10.20

Bash Version: 4.0
Patch Level: 10
Release Status: release

Description:
Strings compared with [[ string1 < string2 ]] are supposed to use
the current locale, but they don't.

Repeat-By:
imadev:/tmp/greg$ ls
ab  Ac
imadev:/tmp/greg$ [[ ab < Ac ]]; echo $?
1
imadev:/tmp/greg$ locale
LANG=en_US.iso88591
LC_CTYPE="en_US.iso88591"
LC_COLLATE="en_US.iso88591"
LC_MONETARY="en_US.iso88591"
LC_NUMERIC="en_US.iso88591"
LC_TIME=POSIX
LC_MESSAGES="en_US.iso88591"
LC_ALL=

Bash appears to be using "C" sorting (ASCII) here.  The current locale
sorts ab before Ac, as ls shows, but bash reverses this.  The exit
status from the [[ command should have been 0 (true).

This error also occurs in 2.05b and 3.2.48 (the only other versions of
bash I tested).