On Wed, Apr 17, 2013 at 2:52 PM, Cedric Blancher
<[email protected]> wrote:
> Glenn, can you take a look at the posting from freebsd-standards? AST
> tr -C doesn't ignore unassigned code points as it should be.
[snip]

Grumpf... I think you're right...
... the trouble is that not all platforms implement the |iswrune()|
function (see 
http://developer.apple.com/library/ios/#documentation/system/conceptual/manpages_iphoneos/man3/iswrune.3.html)
...

... AFAIK (based on some testing on a FreeBSD system vs. Solaris) the
following |iswrune() emulation code should work (and we need a iffe
probe for |iswrune()| and fall-back to the emulation):
-- snip --
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
#include <wctype.h>

static
int iswrune_emu(wint_t c)
{
        /*
         * we test |iswprint()| first because it has
         * usually the largest number of members and
         * the fastest implementation
         */
        if (iswprint(c))
                return (1);
        if (iswalnum(c) ||
                iswcntrl(c) ||
                iswdigit(c) ||
                iswgraph(c) ||
                iswpunct(c) ||
                iswspace(c) ||
                iswxdigit(c) ||
                iswblank(c) ||
                iswlower(c) ||
                iswupper(c))
                return (1);
                
        return (0);
}

int main(int ac, char *av[])
{
        wint_t i;

        setlocale(LC_ALL, "");

        puts("#start.");

        for (i=0x3000 ; i < 0x4000 ; i++)
        {
                if (!iswrune_emu(i))
                {
                        printf("code point %lx not assigned.\n",
                                (long)i);
                }
        }

        puts("#done");
        return (EXIT_SUCCESS);
}
-- snip --
(note that |iswprint()| is explicitly seperated out to highlight the
performace optimisation)

Erm... Glenn... what do you think ?

----

Bye,
Roland

P.S.: If we use the emulation then AST regex should (IMO0 still
support [:rune:] (through the emulation) ...

-- 
  __ .  . __
 (o.\ \/ /.o) [email protected]
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 3992797
 (;O/ \/ \O;)
_______________________________________________
ast-developers mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-developers

Reply via email to