view lib/unigbrk/u32-grapheme-breaks.c @ 14076:bf75753bb6d8

unigbrk: New modules for grapheme clusters. New module 'u8-grapheme-len'. * modules/unigbrk/u8-grapheme-len: New file. * modules/unigbrk/u8-grapheme-len-tests: New file. * lib/unigbrk.in.h: Add prototype for new function. * lib/unigbrk/u8-grapheme-len.c: New file. * tests/unigbrk/test-u8-grapheme-len.c: New file. New module 'u16-grapheme-len'. * modules/unigbrk/u16-grapheme-len: New file. * modules/unigbrk/u16-grapheme-len-tests: New file. * lib/unigbrk.in.h: Add prototype for new function. * lib/unigbrk/u16-grapheme-len.c: New file. * tests/unigbrk/test-u16-grapheme-len.c: New file. New module 'u32-grapheme-len'. * modules/unigbrk/u32-grapheme-len: New file. * modules/unigbrk/u32-grapheme-len-tests: New file. * lib/unigbrk.in.h: Add prototype for new function. * lib/unigbrk/u32-grapheme-len.c: New file. * tests/unigbrk/test-u32-grapheme-len.c: New file. New module 'u8-grapheme-next'. * modules/unigbrk/u8-grapheme-next: New file. * modules/unigbrk/u8-grapheme-next-tests: New file. * lib/unigbrk.in.h: Add prototype for new function. * lib/unigbrk/u8-grapheme-next.c: New file. * tests/unigbrk/test-u8-grapheme-next.c: New file. New module 'u16-grapheme-next'. * modules/unigbrk/u16-grapheme-next: New file. * modules/unigbrk/u16-grapheme-next-tests: New file. * lib/unigbrk.in.h: Add prototype for new function. * lib/unigbrk/u16-grapheme-next.c: New file. * tests/unigbrk/test-u16-grapheme-next.c: New file. New module 'u32-grapheme-next'. * modules/unigbrk/u32-grapheme-next: New file. * modules/unigbrk/u32-grapheme-next-tests: New file. * lib/unigbrk.in.h: Add prototype for new function. * lib/unigbrk/u32-grapheme-next.c: New file. * tests/unigbrk/test-u32-grapheme-next.c: New file. New module 'u8-grapheme-prev'. * modules/unigbrk/u8-grapheme-prev: New file. * modules/unigbrk/u8-grapheme-prev-tests: New file. * lib/unigbrk.in.h: Add prototype for new function. * lib/unigbrk/u8-grapheme-prev.c: New file. * tests/unigbrk/test-u8-grapheme-prev.c: New file. New module 'u16-grapheme-prev'. * modules/unigbrk/u16-grapheme-prev: New file. * modules/unigbrk/u16-grapheme-prev-tests: New file. * lib/unigbrk.in.h: Add prototype for new function. * lib/unigbrk/u16-grapheme-prev.c: New file. * tests/unigbrk/test-u16-grapheme-prev.c: New file. New module 'u32-grapheme-prev'. * modules/unigbrk/u32-grapheme-prev: New file. * modules/unigbrk/u32-grapheme-prev-tests: New file. * lib/unigbrk.in.h: Add prototype for new function. * lib/unigbrk/u32-grapheme-prev.c: New file. * tests/unigbrk/test-u32-grapheme-prev.c: New file. New module 'u8-grapheme-breaks'. * modules/unigbrk/u8-grapheme-breaks: New file. * modules/unigbrk/u8-grapheme-breaks-tests: New file. * lib/unigbrk.in.h: Add prototype for new function. * lib/unigbrk/u8-grapheme-breaks.c: New file. * tests/unigbrk/test-u8-grapheme-breaks.c: New file. New module 'u16-grapheme-breaks'. * modules/unigbrk/u16-grapheme-breaks: New file. * modules/unigbrk/u16-grapheme-breaks-tests: New file. * lib/unigbrk.in.h: Add prototype for new function. * lib/unigbrk/u16-grapheme-breaks.c: New file. * tests/unigbrk/test-u16-grapheme-breaks.c: New file. New module 'u32-grapheme-breaks'. * modules/unigbrk/u32-grapheme-breaks: New file. * modules/unigbrk/u32-grapheme-breaks-tests: New file. * lib/unigbrk.in.h: Add prototype for new function. * lib/unigbrk/u32-grapheme-breaks.c: New file. * tests/unigbrk/test-u32-grapheme-breaks.c: New file. New module 'ulc-grapheme-breaks'. * modules/unigbrk/ulc-grapheme-breaks: New file. * modules/unigbrk/ulc-grapheme-breaks-tests: New file. * m4/locale-ar.m4: New file. * lib/unigbrk/ulc-grapheme-breaks.c: New file. * tests/unigbrk/test-ulc-grapheme-breaks.c: New file. * tests/unigbrk/test-ulc-grapheme-breaks.sh: New file.
author Ben Pfaff <blp@cs.stanford.edu>
date Sat, 01 Jan 2011 08:47:34 -0800
parents
children 97fc9a21a8fb
line wrap: on
line source

/* Grapheme cluster breaks function.
   Copyright (C) 2010 Free Software Foundation, Inc.
   Written by Ben Pfaff <blp@cs.stanford.edu>, 2010.

   This program is free software: you can redistribute it and/or modify it
   under the terms of the GNU Lesser General Public License as published
   by the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

#include <config.h>

/* Specification.  */
#include "unigbrk.h"

#include "unistr.h"

void
u32_grapheme_breaks (const uint32_t *s, size_t n, char *p)
{
  ucs4_t prev;
  size_t i;

  prev = 0;
  for (i = 0; i < n; i++)
    {
      ucs4_t next;

      u32_mbtouc (&next, &s[i], 1);

      p[i] = uc_is_grapheme_cluster_break (prev, next);

      prev = next;
    }
}