Back to index

courier  0.68.2
Defines | Functions
unicode_graphemebreak.c File Reference
#include "unicode_config.h"
#include "unicode.h"
#include <unistd.h>
#include <stdint.h>
#include <stdlib.h>
#include "graphemebreaktab.h"

Go to the source code of this file.

Defines

#define UNICODE_GRAPHEMEBREAK_ANY   0x00
#define UNICODE_GRAPHEMEBREAK_CR   0x01
#define UNICODE_GRAPHEMEBREAK_LF   0x02
#define UNICODE_GRAPHEMEBREAK_Control   0x03
#define UNICODE_GRAPHEMEBREAK_Extend   0x04
#define UNICODE_GRAPHEMEBREAK_Prepend   0x05
#define UNICODE_GRAPHEMEBREAK_SpacingMark   0x06
#define UNICODE_GRAPHEMEBREAK_L   0x07
#define UNICODE_GRAPHEMEBREAK_V   0x08
#define UNICODE_GRAPHEMEBREAK_T   0x09
#define UNICODE_GRAPHEMEBREAK_LV   0x0A
#define UNICODE_GRAPHEMEBREAK_LVT   0x0B

Functions

int unicode_grapheme_break (unicode_char a, unicode_char b)

Define Documentation

#define UNICODE_GRAPHEMEBREAK_ANY   0x00

Definition at line 13 of file unicode_graphemebreak.c.

#define UNICODE_GRAPHEMEBREAK_Control   0x03

Definition at line 16 of file unicode_graphemebreak.c.

#define UNICODE_GRAPHEMEBREAK_CR   0x01

Definition at line 14 of file unicode_graphemebreak.c.

#define UNICODE_GRAPHEMEBREAK_Extend   0x04

Definition at line 17 of file unicode_graphemebreak.c.

#define UNICODE_GRAPHEMEBREAK_L   0x07

Definition at line 20 of file unicode_graphemebreak.c.

#define UNICODE_GRAPHEMEBREAK_LF   0x02

Definition at line 15 of file unicode_graphemebreak.c.

#define UNICODE_GRAPHEMEBREAK_LV   0x0A

Definition at line 23 of file unicode_graphemebreak.c.

#define UNICODE_GRAPHEMEBREAK_LVT   0x0B

Definition at line 24 of file unicode_graphemebreak.c.

#define UNICODE_GRAPHEMEBREAK_Prepend   0x05

Definition at line 18 of file unicode_graphemebreak.c.

Definition at line 19 of file unicode_graphemebreak.c.

#define UNICODE_GRAPHEMEBREAK_T   0x09

Definition at line 22 of file unicode_graphemebreak.c.

#define UNICODE_GRAPHEMEBREAK_V   0x08

Definition at line 21 of file unicode_graphemebreak.c.


Function Documentation

Definition at line 28 of file unicode_graphemebreak.c.

{
       uint8_t ac=unicode_tab_lookup(a, unicode_indextab,
                      sizeof(unicode_indextab)/sizeof(unicode_indextab[0]),
                      unicode_rangetab,
                      unicode_classtab,
                      UNICODE_GRAPHEMEBREAK_ANY),
              bc=unicode_tab_lookup(b, unicode_indextab,
                      sizeof(unicode_indextab)/sizeof(unicode_indextab[0]),
                      unicode_rangetab,
                      unicode_classtab,
                      UNICODE_GRAPHEMEBREAK_ANY);

       /* GB1 and GB2 are implied */

       if (ac == UNICODE_GRAPHEMEBREAK_CR && bc == UNICODE_GRAPHEMEBREAK_LF)
              return 0; /* GB3 */


       switch (ac) {
       case UNICODE_GRAPHEMEBREAK_CR:
       case UNICODE_GRAPHEMEBREAK_LF:
       case UNICODE_GRAPHEMEBREAK_Control:
              return 1; /* GB4 */
       default:
              break;
       }

       switch (bc) {
       case UNICODE_GRAPHEMEBREAK_CR:
       case UNICODE_GRAPHEMEBREAK_LF:
       case UNICODE_GRAPHEMEBREAK_Control:
              return 1; /* GB5 */
       default:
              break;
       }

       if (ac == UNICODE_GRAPHEMEBREAK_L)
              switch (bc) {
              case UNICODE_GRAPHEMEBREAK_L:
              case UNICODE_GRAPHEMEBREAK_V:
              case UNICODE_GRAPHEMEBREAK_LV:
              case UNICODE_GRAPHEMEBREAK_LVT:
                     return 0; /* GB6 */
              }

       if ((ac == UNICODE_GRAPHEMEBREAK_LV ||
            ac == UNICODE_GRAPHEMEBREAK_V) &&
           (bc == UNICODE_GRAPHEMEBREAK_V ||
            bc == UNICODE_GRAPHEMEBREAK_T))
              return 0; /* GB7 */

       if ((ac == UNICODE_GRAPHEMEBREAK_LVT ||
            ac == UNICODE_GRAPHEMEBREAK_T) &&
           bc == UNICODE_GRAPHEMEBREAK_T)
              return 0; /* GB8 */

       if (bc == UNICODE_GRAPHEMEBREAK_Extend)
              return 0; /* GB9 */

       if (bc == UNICODE_GRAPHEMEBREAK_SpacingMark)
              return 0; /* GB9a */

       if (ac == UNICODE_GRAPHEMEBREAK_Prepend)
              return 0; /* GB9b */

       return 1; /* GB10 */
}

Here is the call graph for this function:

Here is the caller graph for this function: