X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Funilbrk%2Fu32-width-linebreaks.c;h=61ec21d19e011ca71633697c56e9b94e649b4d46;hb=b344de996cd51f8a2f2558a3172016b64d99c622;hp=2d36256095f57b16a5bd1d7fe001a680f6a84527;hpb=9abda809d44be61025d67d5980a4e780010c7b5b;p=gnulib.git diff --git a/lib/unilbrk/u32-width-linebreaks.c b/lib/unilbrk/u32-width-linebreaks.c index 2d3625609..61ec21d19 100644 --- a/lib/unilbrk/u32-width-linebreaks.c +++ b/lib/unilbrk/u32-width-linebreaks.c @@ -1,5 +1,5 @@ /* Line breaking of UTF-32 strings. - Copyright (C) 2001-2003, 2006-2008 Free Software Foundation, Inc. + Copyright (C) 2001-2003, 2006-2011 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software: you can redistribute it and/or modify it @@ -24,9 +24,9 @@ int u32_width_linebreaks (const uint32_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 uint32_t *s_end; char *last_p; @@ -45,53 +45,53 @@ u32_width_linebreaks (const uint32_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++; p++; if (o != NULL) - o++; + o++; } /* The last atomic piece of text ends here. */