diff options
Diffstat (limited to 'lib/unilbrk/u16-width-linebreaks.c')
-rw-r--r-- | lib/unilbrk/u16-width-linebreaks.c | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/lib/unilbrk/u16-width-linebreaks.c b/lib/unilbrk/u16-width-linebreaks.c index 6444559..152178e 100644 --- a/lib/unilbrk/u16-width-linebreaks.c +++ b/lib/unilbrk/u16-width-linebreaks.c @@ -1,5 +1,5 @@ /* Line breaking of UTF-16 strings. - Copyright (C) 2001-2003, 2006-2008 Free Software Foundation, Inc. + Copyright (C) 2001-2003, 2006-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2001. This program is free software: you can redistribute it and/or modify it @@ -25,9 +25,9 @@ int u16_width_linebreaks (const uint16_t *s, size_t n, - int width, int start_column, int at_end_columns, - const char *o, const char *encoding, - char *p) + int width, int start_column, int at_end_columns, + const char *o, const char *encoding, + char *p) { const uint16_t *s_end; char *last_p; @@ -47,53 +47,53 @@ u16_width_linebreaks (const uint16_t *s, size_t n, /* Respect the override. */ if (o != NULL && *o != UC_BREAK_UNDEFINED) - *p = *o; + *p = *o; if (*p == UC_BREAK_POSSIBLE || *p == UC_BREAK_MANDATORY) - { - /* An atomic piece of text ends here. */ - if (last_p != NULL && last_column + piece_width > width) - { - /* Insert a line break. */ - *last_p = UC_BREAK_POSSIBLE; - last_column = 0; - } - } + { + /* An atomic piece of text ends here. */ + if (last_p != NULL && last_column + piece_width > width) + { + /* Insert a line break. */ + *last_p = UC_BREAK_POSSIBLE; + last_column = 0; + } + } if (*p == UC_BREAK_MANDATORY) - { - /* uc is a line break character. */ - /* Start a new piece at column 0. */ - last_p = NULL; - last_column = 0; - piece_width = 0; - } + { + /* uc is a line break character. */ + /* Start a new piece at column 0. */ + last_p = NULL; + last_column = 0; + piece_width = 0; + } else - { - /* uc is not a line break character. */ - int w; - - if (*p == UC_BREAK_POSSIBLE) - { - /* Start a new piece. */ - last_p = p; - last_column += piece_width; - piece_width = 0; - /* No line break for the moment, may be turned into - UC_BREAK_POSSIBLE later, via last_p. */ - } - - *p = UC_BREAK_PROHIBITED; - - w = uc_width (uc, encoding); - if (w >= 0) /* ignore control characters in the string */ - piece_width += w; - } + { + /* uc is not a line break character. */ + int w; + + if (*p == UC_BREAK_POSSIBLE) + { + /* Start a new piece. */ + last_p = p; + last_column += piece_width; + piece_width = 0; + /* No line break for the moment, may be turned into + UC_BREAK_POSSIBLE later, via last_p. */ + } + + *p = UC_BREAK_PROHIBITED; + + w = uc_width (uc, encoding); + if (w >= 0) /* ignore control characters in the string */ + piece_width += w; + } s += count; p += count; if (o != NULL) - o += count; + o += count; } /* The last atomic piece of text ends here. */ |