According to Geoff Hutchison:
> On Thursday, September 19, 2002, at 03:05  PM, Gilles Detillieux wrote:
> > Now, from a developer perspective, I guess we need to decide whether
> > we make this change permanently to the source, and force it for all
> > systems (which I imagine may break things on other systems), or do we
> > come up with a configure test for this?
> 
> It's pretty easy to write a configure test for something like this. 
> Basically if you had some test code, you could compile and check the 
> output. The code would need to consider if some words with 8-bit 
> characters pass through parsing, say with LC_CTYPE If not, call 
> return(1);
> 
> If someone's willing to write the testcode, I'll be happy to 
> configurify(?) it.

The actual test code is quite simple.  The trick is to find a locale
that's installed and working.  We could make the configure script try a
whole series of locales until it finds one that works.  If it doesn't find
any that work with LC_ALL, it tries the whole series again with LC_CTYPE.
The stipulation would be that for ht://Dig to properly configure locale
support, the system would need to have at least one of these specified
locale definitions installed.  If all tests fail, then the code can
default to LC_ALL or LC_CTYPE, whichever we think is more reasonable.

Here's the test code, which would be called with 2 arguments: LC_ALL or
LC_CTYPE as arg 1, and the locale as arg 2.  It will require a locale
to have at least 4 letters in the upper half, with at least 2 of these
mapping to a different lower case letter in the upper half.

#include <ctype.h>
#include <locale.h>

main(int ac, char **av)
{
        int     i, j, l, m;
        char    *s = "fr_FR";

        if (ac > 2)
                s = av[2];
        if (ac > 1 && strlen(av[1]) > 3 && tolower(av[1][3]) == 'a')
                setlocale(LC_ALL, s);
        else
                setlocale(LC_CTYPE, s);

        l = m = 0;
        for (i = 128; i < 256; ++i) {
                if (isalpha((unsigned char)i)) {
                        ++l;
                        if ((j = tolower((unsigned char)i)) != i && j >= 128
                            && islower((unsigned char)j))
                                ++m;
                }
        }
        return (l >= 4 && m >= 2)? 0 : 1;
}


-- 
Gilles R. Detillieux              E-mail: <[EMAIL PROTECTED]>
Spinal Cord Research Centre       WWW:    http://www.scrc.umanitoba.ca/
Dept. Physiology, U. of Manitoba  Winnipeg, MB  R3E 3J7  (Canada)


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
htdig-general mailing list <[EMAIL PROTECTED]>
To unsubscribe, send a message to <[EMAIL PROTECTED]> with a 
subject of unsubscribe
FAQ: http://htdig.sourceforge.net/FAQ.html

Reply via email to