X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Flinebreak.c;h=73dba732d4a7991a1ae277182a5ecfe2f5dc87b6;hb=fe0f080532b2357794d4e25d66a35f4aedc4f93a;hp=78fb657e6215b329464f5f5d8651c9845e501073;hpb=a1d462a378bebcdb57d628c501fa2c008c7f05a9;p=gnulib.git diff --git a/lib/linebreak.c b/lib/linebreak.c index 78fb657e6..73dba732d 100644 --- a/lib/linebreak.c +++ b/lib/linebreak.c @@ -1,5 +1,5 @@ /* linebreak.c - line breaking of Unicode strings - Copyright (C) 2001-2003 Free Software Foundation, Inc. + Copyright (C) 2001-2003, 2006-2007 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software; you can redistribute it and/or modify @@ -13,12 +13,10 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +along with this program; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifdef HAVE_CONFIG_H -# include -#endif +#include /* Specification. */ #include "linebreak.h" @@ -27,14 +25,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include "c-ctype.h" #include "xsize.h" - -#include "utf8-ucs4.h" - -#include "utf16-ucs4.h" +#include "unistr.h" #ifdef unused static inline int -u32_mbtouc (unsigned int *puc, const unsigned int *s, size_t n) +u32_mbtouc_unsafe (unsigned int *puc, const unsigned int *s, size_t n) { *puc = *s; return 1; @@ -474,7 +469,7 @@ u8_width (const unsigned char *s, size_t n, const char *encoding) unsigned int uc; int w; - s += u8_mbtouc (&uc, s, s_end - s); + s += u8_mbtouc_unsafe (&uc, s, s_end - s); if (uc == 0) break; /* end of string reached */ @@ -498,7 +493,7 @@ u16_width (const unsigned short *s, size_t n, const char *encoding) unsigned int uc; int w; - s += u16_mbtouc (&uc, s, s_end - s); + s += u16_mbtouc_unsafe (&uc, s, s_end - s); if (uc == 0) break; /* end of string reached */ @@ -644,7 +639,7 @@ u8_possible_linebreaks (const unsigned char *s, size_t n, const char *encoding, while (s < s_end) { unsigned int uc; - int count = u8_mbtouc (&uc, s, s_end - s); + int count = u8_mbtouc_unsafe (&uc, s, s_end - s); int prop = lbrkprop_lookup (uc); if (prop == LBP_BK) @@ -756,7 +751,7 @@ u16_possible_linebreaks (const unsigned short *s, size_t n, const char *encoding while (s < s_end) { unsigned int uc; - int count = u16_mbtouc (&uc, s, s_end - s); + int count = u16_mbtouc_unsafe (&uc, s, s_end - s); int prop = lbrkprop_lookup (uc); if (prop == LBP_BK) @@ -985,7 +980,7 @@ u8_width_linebreaks (const unsigned char *s, size_t n, while (s < s_end) { unsigned int uc; - int count = u8_mbtouc (&uc, s, s_end - s); + int count = u8_mbtouc_unsafe (&uc, s, s_end - s); /* Respect the override. */ if (o != NULL && *o != UC_BREAK_UNDEFINED) @@ -1024,7 +1019,7 @@ u8_width_linebreaks (const unsigned char *s, size_t n, /* 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); @@ -1069,7 +1064,7 @@ u16_width_linebreaks (const unsigned short *s, size_t n, while (s < s_end) { unsigned int uc; - int count = u16_mbtouc (&uc, s, s_end - s); + int count = u16_mbtouc_unsafe (&uc, s, s_end - s); /* Respect the override. */ if (o != NULL && *o != UC_BREAK_UNDEFINED) @@ -1108,7 +1103,7 @@ u16_width_linebreaks (const unsigned short *s, size_t n, /* 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); @@ -1191,7 +1186,7 @@ u32_width_linebreaks (const unsigned int *s, size_t n, /* 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); @@ -1619,6 +1614,7 @@ mbs_width_linebreaks (const char *s, size_t n, xsum4 (xtimes (n, sizeof (size_t)), m, m, (o != NULL ? m : 0)); char *memory = + (char *) (size_in_bounds_p (memory_size) ? malloc (memory_size) : NULL); if (memory != NULL) {