There are problems with setlocale on some systems, such as Linux 2.0.30
glibc 2.0.7-19, libg++-devel-2.7.2.8-6 on Alpha.  For the record, this
problem is also present in htdig-3.1.0b4.

Thanks to Kevin Quinn at BitWrench for providing a testbed for diagnosing
this problem.

The following small test-program crashes with a segfault, if run with a
nondefault locale, such as:

 ./a.out en_US

(replace en_US with any locally invalid locale)
but runs to completion as:

 ./a.out C

------------ snip
#include <iostream.h>
#include <locale.h>
#include <stdio.h>

main(int argc, char **argv)
{
  char *rc;
  if (argc != 2)
  {
    printf("Usage: localetest locale\n");
    exit(1);
  }

  printf("Testing %s\n", argv[1]);
  rc= setlocale(LC_ALL, argv[1]);
  if (rc== NULL)
    printf("locale \"%s\" not supported!\n", argv[1]);
  else
    printf("locale set to \"%s\".\n", rc);
  cout << "Everything is super, your system has no locale problems" << endl;
  exit(0);
}
------------ snip

It will run correctly if the "cout" line is removed, which leads me to
believe that this is a bad interaction between global constructors for the
iostreams and the locale functionality.

By the way, *any* system that does not like the locale "iso_8859_1"
will complain with that ubiquitous "unknown locale" warning, regardless of
htdig.conf settings, as defaults.cc is used to set the locale (once)
before any configuration file is read.

The most reasonable thing to do IMO, is to change the default for locale
to actually be "C", since "iso_8859_1" is broken often enough to give
problems, and people who need to change it often need something other
than iso_8859_1.
 This change also more clearly points out the locale functionality as the
troublemaker, so people will have a clue what to update, if they need
to change the locale and get problems.

Sorry folks, I will probably *not* take this problem further to e.g. the
glibc people (or the libstdc++ people).  I just recommend an update to
egcs-1.1.1 (or 1.1.2 RSN) and the appropriate libraries.

For ht://Dig, I propose this patch.  I did not commit this right away,
since I'm not fluent enough in locale issues to be sure I did not break
something.

diff -p -c -r1.43 defaults.cc
*** htcommon/defaults.cc        1999/01/27 00:25:07     1.43
--- htcommon/defaults.cc        1999/02/16 23:23:15
*************** ConfigDefaults  defaults[] =
*** 70,76 ****
      {"keywords_meta_tag_names",               "keywords
htdig-keywords"},
      {"limit_urls_to",                 "${start_url}"},
      {"limit_normalized",                ""},
!     {"locale",                                "iso_8859_1"},
      {"local_default_doc",               "index.html"},
      {"local_urls",                    ""},
      {"local_user_urls",                       ""},
--- 70,76 ----
      {"keywords_meta_tag_names",               "keywords
htdig-keywords"},
      {"limit_urls_to",                 "${start_url}"},
      {"limit_normalized",                ""},
!     {"locale",                                "C"},
      {"local_default_doc",               "index.html"},
      {"local_urls",                    ""},
      {"local_user_urls",                       ""},

brgds, H-P



------------------------------------
To unsubscribe from the htdig3-dev mailing list, send a message to
[EMAIL PROTECTED] containing the single word "unsubscribe" in
the SUBJECT of the message.

Reply via email to