summaryrefslogtreecommitdiff
path: root/lib/unilbrk
diff options
context:
space:
mode:
Diffstat (limited to 'lib/unilbrk')
-rw-r--r--lib/unilbrk/lbrkprop1.h2
-rw-r--r--lib/unilbrk/lbrkprop2.h2
-rw-r--r--lib/unilbrk/lbrktables.c6
-rw-r--r--lib/unilbrk/lbrktables.h20
-rw-r--r--lib/unilbrk/u16-possible-linebreaks.c216
-rw-r--r--lib/unilbrk/u16-width-linebreaks.c84
-rw-r--r--lib/unilbrk/u32-possible-linebreaks.c216
-rw-r--r--lib/unilbrk/u32-width-linebreaks.c84
-rw-r--r--lib/unilbrk/u8-possible-linebreaks.c290
-rw-r--r--lib/unilbrk/u8-width-linebreaks.c152
-rw-r--r--lib/unilbrk/ulc-common.c4
-rw-r--r--lib/unilbrk/ulc-common.h2
-rw-r--r--lib/unilbrk/ulc-possible-linebreaks.c196
-rw-r--r--lib/unilbrk/ulc-width-linebreaks.c232
14 files changed, 753 insertions, 753 deletions
diff --git a/lib/unilbrk/lbrkprop1.h b/lib/unilbrk/lbrkprop1.h
index 66fd584..ba6e1b8 100644
--- a/lib/unilbrk/lbrkprop1.h
+++ b/lib/unilbrk/lbrkprop1.h
@@ -2,7 +2,7 @@
/* Line breaking properties of Unicode characters. */
/* Generated automatically by gen-lbrk for Unicode 5.1.0. */
-/* Copyright (C) 2000-2002, 2004, 2008 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2002, 2004, 2008-2010 Free Software Foundation, Inc.
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
diff --git a/lib/unilbrk/lbrkprop2.h b/lib/unilbrk/lbrkprop2.h
index a71b4d9..45b93b1 100644
--- a/lib/unilbrk/lbrkprop2.h
+++ b/lib/unilbrk/lbrkprop2.h
@@ -2,7 +2,7 @@
/* Line breaking properties of Unicode characters. */
/* Generated automatically by gen-lbrk for Unicode 5.1.0. */
-/* Copyright (C) 2000-2002, 2004, 2008 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2002, 2004, 2008-2010 Free Software Foundation, Inc.
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
diff --git a/lib/unilbrk/lbrktables.c b/lib/unilbrk/lbrktables.c
index ae3ebf4..fbc8931 100644
--- a/lib/unilbrk/lbrktables.c
+++ b/lib/unilbrk/lbrktables.c
@@ -1,5 +1,5 @@
/* Line breaking auxiliary tables.
- Copyright (C) 2001-2003, 2006-2009 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,8 +25,8 @@
const unsigned char unilbrk_table[24][24] =
{
- /* after */
- /* WJ GL B2 BA BB HY CL EX IN NS OP QU IS NU PO PR SY AL H2 H3 ID JL JV JT */
+ /* after */
+ /* WJ GL B2 BA BB HY CL EX IN NS OP QU IS NU PO PR SY AL H2 H3 ID JL JV JT */
/* WJ */ { P, I, I, I, I, I, P, P, I, I, I, I, P, I, I, I, P, I, I, I, I, I, I, I, },
/* GL */ { P, I, I, I, I, I, P, P, I, I, I, I, P, I, I, I, P, I, I, I, I, I, I, I, },
/* B2 */ { P, I, P, I, D, I, P, P, D, I, D, I, P, D, D, D, P, D, D, D, D, D, D, D, },
diff --git a/lib/unilbrk/lbrktables.h b/lib/unilbrk/lbrktables.h
index 33b525b..e86c49f 100644
--- a/lib/unilbrk/lbrktables.h
+++ b/lib/unilbrk/lbrktables.h
@@ -1,5 +1,5 @@
/* Line breaking auxiliary tables.
- 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
@@ -70,15 +70,15 @@ unilbrkprop_lookup (ucs4_t uc)
{
int lookup1 = unilbrkprop.level1[index1];
if (lookup1 >= 0)
- {
- unsigned int index2 = (uc >> lbrkprop_header_2) & lbrkprop_header_3;
- int lookup2 = unilbrkprop.level2[lookup1 + index2];
- if (lookup2 >= 0)
- {
- unsigned int index3 = uc & lbrkprop_header_4;
- return unilbrkprop.level3[lookup2 + index3];
- }
- }
+ {
+ unsigned int index2 = (uc >> lbrkprop_header_2) & lbrkprop_header_3;
+ int lookup2 = unilbrkprop.level2[lookup1 + index2];
+ if (lookup2 >= 0)
+ {
+ unsigned int index3 = uc & lbrkprop_header_4;
+ return unilbrkprop.level3[lookup2 + index3];
+ }
+ }
}
return LBP_XX;
}
diff --git a/lib/unilbrk/u16-possible-linebreaks.c b/lib/unilbrk/u16-possible-linebreaks.c
index f5b6992..25b9851 100644
--- a/lib/unilbrk/u16-possible-linebreaks.c
+++ b/lib/unilbrk/u16-possible-linebreaks.c
@@ -1,5 +1,5 @@
/* Line breaking of UTF-16 strings.
- Copyright (C) 2001-2003, 2006-2009 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
@@ -46,117 +46,117 @@ u16_possible_linebreaks (const uint16_t *s, size_t n, const char *encoding, char
int prop = unilbrkprop_lookup (uc);
if (prop == LBP_BK)
- {
- /* Mandatory break. */
- *p = UC_BREAK_MANDATORY;
- last_prop = LBP_BK;
- seen_space = NULL;
- seen_space2 = NULL;
- }
+ {
+ /* Mandatory break. */
+ *p = UC_BREAK_MANDATORY;
+ last_prop = LBP_BK;
+ seen_space = NULL;
+ seen_space2 = NULL;
+ }
else
- {
- char *q;
+ {
+ char *q;
- /* Resolve property values whose behaviour is not fixed. */
- switch (prop)
- {
- case LBP_AI:
- /* Resolve ambiguous. */
- prop = LBP_AI_REPLACEMENT;
- break;
- case LBP_CB:
- /* This is arbitrary. */
- prop = LBP_ID;
- break;
- case LBP_SA:
- /* We don't handle complex scripts yet.
- Treat LBP_SA like LBP_XX. */
- case LBP_XX:
- /* This is arbitrary. */
- prop = LBP_AL;
- break;
- }
+ /* Resolve property values whose behaviour is not fixed. */
+ switch (prop)
+ {
+ case LBP_AI:
+ /* Resolve ambiguous. */
+ prop = LBP_AI_REPLACEMENT;
+ break;
+ case LBP_CB:
+ /* This is arbitrary. */
+ prop = LBP_ID;
+ break;
+ case LBP_SA:
+ /* We don't handle complex scripts yet.
+ Treat LBP_SA like LBP_XX. */
+ case LBP_XX:
+ /* This is arbitrary. */
+ prop = LBP_AL;
+ break;
+ }
- /* Deal with spaces and combining characters. */
- q = p;
- if (prop == LBP_SP)
- {
- /* Don't break just before a space. */
- *p = UC_BREAK_PROHIBITED;
- seen_space2 = seen_space;
- seen_space = p;
- }
- else if (prop == LBP_ZW)
- {
- /* Don't break just before a zero-width space. */
- *p = UC_BREAK_PROHIBITED;
- last_prop = LBP_ZW;
- seen_space = NULL;
- seen_space2 = NULL;
- }
- else if (prop == LBP_CM)
- {
- /* Don't break just before a combining character, except immediately after a
- zero-width space. */
- if (last_prop == LBP_ZW)
- {
- /* Break after zero-width space. */
- *p = UC_BREAK_POSSIBLE;
- /* A combining character turns a preceding space into LBP_ID. */
- last_prop = LBP_ID;
- }
- else
- {
- *p = UC_BREAK_PROHIBITED;
- /* A combining character turns a preceding space into LBP_ID. */
- if (seen_space != NULL)
- {
- q = seen_space;
- seen_space = seen_space2;
- prop = LBP_ID;
- goto lookup_via_table;
- }
- }
- }
- else
- {
- lookup_via_table:
- /* prop must be usable as an index for table 7.3 of UTR #14. */
- if (!(prop >= 0 && prop < sizeof (unilbrk_table) / sizeof (unilbrk_table[0])))
- abort ();
+ /* Deal with spaces and combining characters. */
+ q = p;
+ if (prop == LBP_SP)
+ {
+ /* Don't break just before a space. */
+ *p = UC_BREAK_PROHIBITED;
+ seen_space2 = seen_space;
+ seen_space = p;
+ }
+ else if (prop == LBP_ZW)
+ {
+ /* Don't break just before a zero-width space. */
+ *p = UC_BREAK_PROHIBITED;
+ last_prop = LBP_ZW;
+ seen_space = NULL;
+ seen_space2 = NULL;
+ }
+ else if (prop == LBP_CM)
+ {
+ /* Don't break just before a combining character, except immediately after a
+ zero-width space. */
+ if (last_prop == LBP_ZW)
+ {
+ /* Break after zero-width space. */
+ *p = UC_BREAK_POSSIBLE;
+ /* A combining character turns a preceding space into LBP_ID. */
+ last_prop = LBP_ID;
+ }
+ else
+ {
+ *p = UC_BREAK_PROHIBITED;
+ /* A combining character turns a preceding space into LBP_ID. */
+ if (seen_space != NULL)
+ {
+ q = seen_space;
+ seen_space = seen_space2;
+ prop = LBP_ID;
+ goto lookup_via_table;
+ }
+ }
+ }
+ else
+ {
+ lookup_via_table:
+ /* prop must be usable as an index for table 7.3 of UTR #14. */
+ if (!(prop >= 0 && prop < sizeof (unilbrk_table) / sizeof (unilbrk_table[0])))
+ abort ();
- if (last_prop == LBP_BK)
- {
- /* Don't break at the beginning of a line. */
- *q = UC_BREAK_PROHIBITED;
- }
- else if (last_prop == LBP_ZW)
- {
- /* Break after zero-width space. */
- *q = UC_BREAK_POSSIBLE;
- }
- else
- {
- switch (unilbrk_table [last_prop] [prop])
- {
- case D:
- *q = UC_BREAK_POSSIBLE;
- break;
- case I:
- *q = (seen_space != NULL ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED);
- break;
- case P:
- *q = UC_BREAK_PROHIBITED;
- break;
- default:
- abort ();
- }
- }
- last_prop = prop;
- seen_space = NULL;
- seen_space2 = NULL;
- }
- }
+ if (last_prop == LBP_BK)
+ {
+ /* Don't break at the beginning of a line. */
+ *q = UC_BREAK_PROHIBITED;
+ }
+ else if (last_prop == LBP_ZW)
+ {
+ /* Break after zero-width space. */
+ *q = UC_BREAK_POSSIBLE;
+ }
+ else
+ {
+ switch (unilbrk_table [last_prop] [prop])
+ {
+ case D:
+ *q = UC_BREAK_POSSIBLE;
+ break;
+ case I:
+ *q = (seen_space != NULL ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED);
+ break;
+ case P:
+ *q = UC_BREAK_PROHIBITED;
+ break;
+ default:
+ abort ();
+ }
+ }
+ last_prop = prop;
+ seen_space = NULL;
+ seen_space2 = NULL;
+ }
+ }
s += count;
p += count;
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. */
diff --git a/lib/unilbrk/u32-possible-linebreaks.c b/lib/unilbrk/u32-possible-linebreaks.c
index c843e12..c375a0c 100644
--- a/lib/unilbrk/u32-possible-linebreaks.c
+++ b/lib/unilbrk/u32-possible-linebreaks.c
@@ -1,5 +1,5 @@
/* Line breaking of UTF-32 strings.
- Copyright (C) 2001-2003, 2006-2009 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
@@ -40,117 +40,117 @@ u32_possible_linebreaks (const uint32_t *s, size_t n, const char *encoding, char
int prop = unilbrkprop_lookup (uc);
if (prop == LBP_BK)
- {
- /* Mandatory break. */
- *p = UC_BREAK_MANDATORY;
- last_prop = LBP_BK;
- seen_space = NULL;
- seen_space2 = NULL;
- }
+ {
+ /* Mandatory break. */
+ *p = UC_BREAK_MANDATORY;
+ last_prop = LBP_BK;
+ seen_space = NULL;
+ seen_space2 = NULL;
+ }
else
- {
- char *q;
+ {
+ char *q;
- /* Resolve property values whose behaviour is not fixed. */
- switch (prop)
- {
- case LBP_AI:
- /* Resolve ambiguous. */
- prop = LBP_AI_REPLACEMENT;
- break;
- case LBP_CB:
- /* This is arbitrary. */
- prop = LBP_ID;
- break;
- case LBP_SA:
- /* We don't handle complex scripts yet.
- Treat LBP_SA like LBP_XX. */
- case LBP_XX:
- /* This is arbitrary. */
- prop = LBP_AL;
- break;
- }
+ /* Resolve property values whose behaviour is not fixed. */
+ switch (prop)
+ {
+ case LBP_AI:
+ /* Resolve ambiguous. */
+ prop = LBP_AI_REPLACEMENT;
+ break;
+ case LBP_CB:
+ /* This is arbitrary. */
+ prop = LBP_ID;
+ break;
+ case LBP_SA:
+ /* We don't handle complex scripts yet.
+ Treat LBP_SA like LBP_XX. */
+ case LBP_XX:
+ /* This is arbitrary. */
+ prop = LBP_AL;
+ break;
+ }
- /* Deal with spaces and combining characters. */
- q = p;
- if (prop == LBP_SP)
- {
- /* Don't break just before a space. */
- *p = UC_BREAK_PROHIBITED;
- seen_space2 = seen_space;
- seen_space = p;
- }
- else if (prop == LBP_ZW)
- {
- /* Don't break just before a zero-width space. */
- *p = UC_BREAK_PROHIBITED;
- last_prop = LBP_ZW;
- seen_space = NULL;
- seen_space2 = NULL;
- }
- else if (prop == LBP_CM)
- {
- /* Don't break just before a combining character, except immediately after a
- zero-width space. */
- if (last_prop == LBP_ZW)
- {
- /* Break after zero-width space. */
- *p = UC_BREAK_POSSIBLE;
- /* A combining character turns a preceding space into LBP_ID. */
- last_prop = LBP_ID;
- }
- else
- {
- *p = UC_BREAK_PROHIBITED;
- /* A combining character turns a preceding space into LBP_ID. */
- if (seen_space != NULL)
- {
- q = seen_space;
- seen_space = seen_space2;
- prop = LBP_ID;
- goto lookup_via_table;
- }
- }
- }
- else
- {
- lookup_via_table:
- /* prop must be usable as an index for table 7.3 of UTR #14. */
- if (!(prop >= 0 && prop < sizeof (unilbrk_table) / sizeof (unilbrk_table[0])))
- abort ();
+ /* Deal with spaces and combining characters. */
+ q = p;
+ if (prop == LBP_SP)
+ {
+ /* Don't break just before a space. */
+ *p = UC_BREAK_PROHIBITED;
+ seen_space2 = seen_space;
+ seen_space = p;
+ }
+ else if (prop == LBP_ZW)
+ {
+ /* Don't break just before a zero-width space. */
+ *p = UC_BREAK_PROHIBITED;
+ last_prop = LBP_ZW;
+ seen_space = NULL;
+ seen_space2 = NULL;
+ }
+ else if (prop == LBP_CM)
+ {
+ /* Don't break just before a combining character, except immediately after a
+ zero-width space. */
+ if (last_prop == LBP_ZW)
+ {
+ /* Break after zero-width space. */
+ *p = UC_BREAK_POSSIBLE;
+ /* A combining character turns a preceding space into LBP_ID. */
+ last_prop = LBP_ID;
+ }
+ else
+ {
+ *p = UC_BREAK_PROHIBITED;
+ /* A combining character turns a preceding space into LBP_ID. */
+ if (seen_space != NULL)
+ {
+ q = seen_space;
+ seen_space = seen_space2;
+ prop = LBP_ID;
+ goto lookup_via_table;
+ }
+ }
+ }
+ else
+ {
+ lookup_via_table:
+ /* prop must be usable as an index for table 7.3 of UTR #14. */
+ if (!(prop >= 0 && prop < sizeof (unilbrk_table) / sizeof (unilbrk_table[0])))
+ abort ();
- if (last_prop == LBP_BK)
- {
- /* Don't break at the beginning of a line. */
- *q = UC_BREAK_PROHIBITED;
- }
- else if (last_prop == LBP_ZW)
- {
- /* Break after zero-width space. */
- *q = UC_BREAK_POSSIBLE;
- }
- else
- {
- switch (unilbrk_table [last_prop] [prop])
- {
- case D:
- *q = UC_BREAK_POSSIBLE;
- break;
- case I:
- *q = (seen_space != NULL ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED);
- break;
- case P:
- *q = UC_BREAK_PROHIBITED;
- break;
- default:
- abort ();
- }
- }
- last_prop = prop;
- seen_space = NULL;
- seen_space2 = NULL;
- }
- }
+ if (last_prop == LBP_BK)
+ {
+ /* Don't break at the beginning of a line. */
+ *q = UC_BREAK_PROHIBITED;
+ }
+ else if (last_prop == LBP_ZW)
+ {
+ /* Break after zero-width space. */
+ *q = UC_BREAK_POSSIBLE;
+ }
+ else
+ {
+ switch (unilbrk_table [last_prop] [prop])
+ {
+ case D:
+ *q = UC_BREAK_POSSIBLE;
+ break;
+ case I:
+ *q = (seen_space != NULL ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED);
+ break;
+ case P:
+ *q = UC_BREAK_PROHIBITED;
+ break;
+ default:
+ abort ();
+ }
+ }
+ last_prop = prop;
+ seen_space = NULL;
+ seen_space2 = NULL;
+ }
+ }
s++;
p++;
diff --git a/lib/unilbrk/u32-width-linebreaks.c b/lib/unilbrk/u32-width-linebreaks.c
index 2d36256..c5803db 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-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
@@ -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. */
diff --git a/lib/unilbrk/u8-possible-linebreaks.c b/lib/unilbrk/u8-possible-linebreaks.c
index 94e14f4..d65335e 100644
--- a/lib/unilbrk/u8-possible-linebreaks.c
+++ b/lib/unilbrk/u8-possible-linebreaks.c
@@ -1,5 +1,5 @@
/* Line breaking of UTF-8 strings.
- Copyright (C) 2001-2003, 2006-2009 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
@@ -46,117 +46,117 @@ u8_possible_linebreaks (const uint8_t *s, size_t n, const char *encoding, char *
int prop = unilbrkprop_lookup (uc);
if (prop == LBP_BK)
- {
- /* Mandatory break. */
- *p = UC_BREAK_MANDATORY;
- last_prop = LBP_BK;
- seen_space = NULL;
- seen_space2 = NULL;
- }
+ {
+ /* Mandatory break. */
+ *p = UC_BREAK_MANDATORY;
+ last_prop = LBP_BK;
+ seen_space = NULL;
+ seen_space2 = NULL;
+ }
else
- {
- char *q;
+ {
+ char *q;
- /* Resolve property values whose behaviour is not fixed. */
- switch (prop)
- {
- case LBP_AI:
- /* Resolve ambiguous. */
- prop = LBP_AI_REPLACEMENT;
- break;
- case LBP_CB:
- /* This is arbitrary. */
- prop = LBP_ID;
- break;
- case LBP_SA:
- /* We don't handle complex scripts yet.
- Treat LBP_SA like LBP_XX. */
- case LBP_XX:
- /* This is arbitrary. */
- prop = LBP_AL;
- break;
- }
+ /* Resolve property values whose behaviour is not fixed. */
+ switch (prop)
+ {
+ case LBP_AI:
+ /* Resolve ambiguous. */
+ prop = LBP_AI_REPLACEMENT;
+ break;
+ case LBP_CB:
+ /* This is arbitrary. */
+ prop = LBP_ID;
+ break;
+ case LBP_SA:
+ /* We don't handle complex scripts yet.
+ Treat LBP_SA like LBP_XX. */
+ case LBP_XX:
+ /* This is arbitrary. */
+ prop = LBP_AL;
+ break;
+ }
- /* Deal with spaces and combining characters. */
- q = p;
- if (prop == LBP_SP)
- {
- /* Don't break just before a space. */
- *p = UC_BREAK_PROHIBITED;
- seen_space2 = seen_space;
- seen_space = p;
- }
- else if (prop == LBP_ZW)
- {
- /* Don't break just before a zero-width space. */
- *p = UC_BREAK_PROHIBITED;
- last_prop = LBP_ZW;
- seen_space = NULL;
- seen_space2 = NULL;
- }
- else if (prop == LBP_CM)
- {
- /* Don't break just before a combining character, except immediately after a
- zero-width space. */
- if (last_prop == LBP_ZW)
- {
- /* Break after zero-width space. */
- *p = UC_BREAK_POSSIBLE;
- /* A combining character turns a preceding space into LBP_ID. */
- last_prop = LBP_ID;
- }
- else
- {
- *p = UC_BREAK_PROHIBITED;
- /* A combining character turns a preceding space into LBP_ID. */
- if (seen_space != NULL)
- {
- q = seen_space;
- seen_space = seen_space2;
- prop = LBP_ID;
- goto lookup_via_table;
- }
- }
- }
- else
- {
- lookup_via_table:
- /* prop must be usable as an index for table 7.3 of UTR #14. */
- if (!(prop >= 0 && prop < sizeof (unilbrk_table) / sizeof (unilbrk_table[0])))
- abort ();
+ /* Deal with spaces and combining characters. */
+ q = p;
+ if (prop == LBP_SP)
+ {
+ /* Don't break just before a space. */
+ *p = UC_BREAK_PROHIBITED;
+ seen_space2 = seen_space;
+ seen_space = p;
+ }
+ else if (prop == LBP_ZW)
+ {
+ /* Don't break just before a zero-width space. */
+ *p = UC_BREAK_PROHIBITED;
+ last_prop = LBP_ZW;
+ seen_space = NULL;
+ seen_space2 = NULL;
+ }
+ else if (prop == LBP_CM)
+ {
+ /* Don't break just before a combining character, except immediately after a
+ zero-width space. */
+ if (last_prop == LBP_ZW)
+ {
+ /* Break after zero-width space. */
+ *p = UC_BREAK_POSSIBLE;
+ /* A combining character turns a preceding space into LBP_ID. */
+ last_prop = LBP_ID;
+ }
+ else
+ {
+ *p = UC_BREAK_PROHIBITED;
+ /* A combining character turns a preceding space into LBP_ID. */
+ if (seen_space != NULL)
+ {
+ q = seen_space;
+ seen_space = seen_space2;
+ prop = LBP_ID;
+ goto lookup_via_table;
+ }
+ }
+ }
+ else
+ {
+ lookup_via_table:
+ /* prop must be usable as an index for table 7.3 of UTR #14. */
+ if (!(prop >= 0 && prop < sizeof (unilbrk_table) / sizeof (unilbrk_table[0])))
+ abort ();
- if (last_prop == LBP_BK)
- {
- /* Don't break at the beginning of a line. */
- *q = UC_BREAK_PROHIBITED;
- }
- else if (last_prop == LBP_ZW)
- {
- /* Break after zero-width space. */
- *q = UC_BREAK_POSSIBLE;
- }
- else
- {
- switch (unilbrk_table [last_prop] [prop])
- {
- case D:
- *q = UC_BREAK_POSSIBLE;
- break;
- case I:
- *q = (seen_space != NULL ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED);
- break;
- case P:
- *q = UC_BREAK_PROHIBITED;
- break;
- default:
- abort ();
- }
- }
- last_prop = prop;
- seen_space = NULL;
- seen_space2 = NULL;
- }
- }
+ if (last_prop == LBP_BK)
+ {
+ /* Don't break at the beginning of a line. */
+ *q = UC_BREAK_PROHIBITED;
+ }
+ else if (last_prop == LBP_ZW)
+ {
+ /* Break after zero-width space. */
+ *q = UC_BREAK_POSSIBLE;
+ }
+ else
+ {
+ switch (unilbrk_table [last_prop] [prop])
+ {
+ case D:
+ *q = UC_BREAK_POSSIBLE;
+ break;
+ case I:
+ *q = (seen_space != NULL ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED);
+ break;
+ case P:
+ *q = UC_BREAK_PROHIBITED;
+ break;
+ default:
+ abort ();
+ }
+ }
+ last_prop = prop;
+ seen_space = NULL;
+ seen_space2 = NULL;
+ }
+ }
s += count;
p += count;
@@ -183,28 +183,28 @@ read_file (FILE *stream)
while (! feof (stream))
{
if (size + BUFSIZE > alloc)
- {
- alloc = alloc + alloc / 2;
- if (alloc < size + BUFSIZE)
- alloc = size + BUFSIZE;
- buf = realloc (buf, alloc);
- if (buf == NULL)
- {
- fprintf (stderr, "out of memory\n");
- exit (1);
- }
- }
+ {
+ alloc = alloc + alloc / 2;
+ if (alloc < size + BUFSIZE)
+ alloc = size + BUFSIZE;
+ buf = realloc (buf, alloc);
+ if (buf == NULL)
+ {
+ fprintf (stderr, "out of memory\n");
+ exit (1);
+ }
+ }
count = fread (buf + size, 1, BUFSIZE, stream);
if (count == 0)
- {
- if (ferror (stream))
- {
- perror ("fread");
- exit (1);
- }
- }
+ {
+ if (ferror (stream))
+ {
+ perror ("fread");
+ exit (1);
+ }
+ }
else
- size += count;
+ size += count;
}
buf = realloc (buf, size + 1);
if (buf == NULL)
@@ -231,24 +231,24 @@ main (int argc, char * argv[])
u8_possible_linebreaks ((uint8_t *) input, length, "UTF-8", breaks);
for (i = 0; i < length; i++)
- {
- switch (breaks[i])
- {
- case UC_BREAK_POSSIBLE:
- /* U+2027 in UTF-8 encoding */
- putc (0xe2, stdout); putc (0x80, stdout); putc (0xa7, stdout);
- break;
- case UC_BREAK_MANDATORY:
- /* U+21B2 (or U+21B5) in UTF-8 encoding */
- putc (0xe2, stdout); putc (0x86, stdout); putc (0xb2, stdout);
- break;
- case UC_BREAK_PROHIBITED:
- break;
- default:
- abort ();
- }
- putc (input[i], stdout);
- }
+ {
+ switch (breaks[i])
+ {
+ case UC_BREAK_POSSIBLE:
+ /* U+2027 in UTF-8 encoding */
+ putc (0xe2, stdout); putc (0x80, stdout); putc (0xa7, stdout);
+ break;
+ case UC_BREAK_MANDATORY:
+ /* U+21B2 (or U+21B5) in UTF-8 encoding */
+ putc (0xe2, stdout); putc (0x86, stdout); putc (0xb2, stdout);
+ break;
+ case UC_BREAK_PROHIBITED:
+ break;
+ default:
+ abort ();
+ }
+ putc (input[i], stdout);
+ }
free (breaks);
diff --git a/lib/unilbrk/u8-width-linebreaks.c b/lib/unilbrk/u8-width-linebreaks.c
index 7e7f2e9..fffe62a 100644
--- a/lib/unilbrk/u8-width-linebreaks.c
+++ b/lib/unilbrk/u8-width-linebreaks.c
@@ -1,5 +1,5 @@
/* Line breaking of UTF-8 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
u8_width_linebreaks (const uint8_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 uint8_t *s_end;
char *last_p;
@@ -47,53 +47,53 @@ u8_width_linebreaks (const uint8_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. */
@@ -128,28 +128,28 @@ read_file (FILE *stream)
while (! feof (stream))
{
if (size + BUFSIZE > alloc)
- {
- alloc = alloc + alloc / 2;
- if (alloc < size + BUFSIZE)
- alloc = size + BUFSIZE;
- buf = realloc (buf, alloc);
- if (buf == NULL)
- {
- fprintf (stderr, "out of memory\n");
- exit (1);
- }
- }
+ {
+ alloc = alloc + alloc / 2;
+ if (alloc < size + BUFSIZE)
+ alloc = size + BUFSIZE;
+ buf = realloc (buf, alloc);
+ if (buf == NULL)
+ {
+ fprintf (stderr, "out of memory\n");
+ exit (1);
+ }
+ }
count = fread (buf + size, 1, BUFSIZE, stream);
if (count == 0)
- {
- if (ferror (stream))
- {
- perror ("fread");
- exit (1);
- }
- }
+ {
+ if (ferror (stream))
+ {
+ perror ("fread");
+ exit (1);
+ }
+ }
else
- size += count;
+ size += count;
}
buf = realloc (buf, size + 1);
if (buf == NULL)
@@ -177,21 +177,21 @@ main (int argc, char * argv[])
u8_width_linebreaks ((uint8_t *) input, length, width, 0, 0, NULL, "UTF-8", breaks);
for (i = 0; i < length; i++)
- {
- switch (breaks[i])
- {
- case UC_BREAK_POSSIBLE:
- putc ('\n', stdout);
- break;
- case UC_BREAK_MANDATORY:
- break;
- case UC_BREAK_PROHIBITED:
- break;
- default:
- abort ();
- }
- putc (input[i], stdout);
- }
+ {
+ switch (breaks[i])
+ {
+ case UC_BREAK_POSSIBLE:
+ putc ('\n', stdout);
+ break;
+ case UC_BREAK_MANDATORY:
+ break;
+ case UC_BREAK_PROHIBITED:
+ break;
+ default:
+ abort ();
+ }
+ putc (input[i], stdout);
+ }
free (breaks);
diff --git a/lib/unilbrk/ulc-common.c b/lib/unilbrk/ulc-common.c
index d035ded..1ed9c82 100644
--- a/lib/unilbrk/ulc-common.c
+++ b/lib/unilbrk/ulc-common.c
@@ -1,5 +1,5 @@
/* Line breaking auxiliary functions.
- 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
@@ -43,7 +43,7 @@ is_all_ascii (const char *s, size_t n)
unsigned char c = (unsigned char) *s;
if (!(c_isprint (c) || c_isspace (c)))
- return 0;
+ return 0;
}
return 1;
}
diff --git a/lib/unilbrk/ulc-common.h b/lib/unilbrk/ulc-common.h
index 3b48188..bd3c6e4 100644
--- a/lib/unilbrk/ulc-common.h
+++ b/lib/unilbrk/ulc-common.h
@@ -1,5 +1,5 @@
/* Line breaking auxiliary functions.
- 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
diff --git a/lib/unilbrk/ulc-possible-linebreaks.c b/lib/unilbrk/ulc-possible-linebreaks.c
index cb95241..eed59b4 100644
--- a/lib/unilbrk/ulc-possible-linebreaks.c
+++ b/lib/unilbrk/ulc-possible-linebreaks.c
@@ -1,5 +1,5 @@
/* Line breaking of strings.
- Copyright (C) 2001-2003, 2006-2009 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
@@ -42,76 +42,76 @@
void
ulc_possible_linebreaks (const char *s, size_t n, const char *encoding,
- char *p)
+ char *p)
{
if (n > 0)
{
if (is_utf8_encoding (encoding))
- u8_possible_linebreaks ((const uint8_t *) s, n, encoding, p);
+ u8_possible_linebreaks ((const uint8_t *) s, n, encoding, p);
else
- {
- /* Convert the string to UTF-8 and build a translation table
- from offsets into s to offsets into the translated string. */
- size_t *offsets = (size_t *) malloc (n * sizeof (size_t));
-
- if (offsets != NULL)
- {
- uint8_t *t;
- size_t m;
-
- t = u8_conv_from_encoding (encoding, iconveh_question_mark,
- s, n, offsets, NULL, &m);
- if (t != NULL)
- {
- char *q = (char *) (m > 0 ? malloc (m) : NULL);
-
- if (m == 0 || q != NULL)
- {
- size_t i;
-
- /* Determine the possible line breaks of the UTF-8
- string. */
- u8_possible_linebreaks (t, m, encoding, q);
-
- /* Translate the result back to the original string. */
- memset (p, UC_BREAK_PROHIBITED, n);
- for (i = 0; i < n; i++)
- if (offsets[i] != (size_t)(-1))
- p[i] = q[offsets[i]];
-
- free (q);
- free (t);
- free (offsets);
- return;
- }
- free (t);
- }
- free (offsets);
- }
-
- /* Impossible to convert. */
+ {
+ /* Convert the string to UTF-8 and build a translation table
+ from offsets into s to offsets into the translated string. */
+ size_t *offsets = (size_t *) malloc (n * sizeof (size_t));
+
+ if (offsets != NULL)
+ {
+ uint8_t *t;
+ size_t m;
+
+ t = u8_conv_from_encoding (encoding, iconveh_question_mark,
+ s, n, offsets, NULL, &m);
+ if (t != NULL)
+ {
+ char *q = (char *) (m > 0 ? malloc (m) : NULL);
+
+ if (m == 0 || q != NULL)
+ {
+ size_t i;
+
+ /* Determine the possible line breaks of the UTF-8
+ string. */
+ u8_possible_linebreaks (t, m, encoding, q);
+
+ /* Translate the result back to the original string. */
+ memset (p, UC_BREAK_PROHIBITED, n);
+ for (i = 0; i < n; i++)
+ if (offsets[i] != (size_t)(-1))
+ p[i] = q[offsets[i]];
+
+ free (q);
+ free (t);
+ free (offsets);
+ return;
+ }
+ free (t);
+ }
+ free (offsets);
+ }
+
+ /* Impossible to convert. */
#if C_CTYPE_ASCII
- if (is_all_ascii (s, n))
- {
- /* ASCII is a subset of UTF-8. */
- u8_possible_linebreaks ((const uint8_t *) s, n, encoding, p);
- return;
- }
+ if (is_all_ascii (s, n))
+ {
+ /* ASCII is a subset of UTF-8. */
+ u8_possible_linebreaks ((const uint8_t *) s, n, encoding, p);
+ return;
+ }
#endif
- /* We have a non-ASCII string and cannot convert it.
- Don't produce line breaks except those already present in the
- input string. All we assume here is that the encoding is
- minimally ASCII compatible. */
- {
- const char *s_end = s + n;
- while (s < s_end)
- {
- *p = (*s == '\n' ? UC_BREAK_MANDATORY : UC_BREAK_PROHIBITED);
- s++;
- p++;
- }
- }
- }
+ /* We have a non-ASCII string and cannot convert it.
+ Don't produce line breaks except those already present in the
+ input string. All we assume here is that the encoding is
+ minimally ASCII compatible. */
+ {
+ const char *s_end = s + n;
+ while (s < s_end)
+ {
+ *p = (*s == '\n' ? UC_BREAK_MANDATORY : UC_BREAK_PROHIBITED);
+ s++;
+ p++;
+ }
+ }
+ }
}
}
@@ -136,28 +136,28 @@ read_file (FILE *stream)
while (! feof (stream))
{
if (size + BUFSIZE > alloc)
- {
- alloc = alloc + alloc / 2;
- if (alloc < size + BUFSIZE)
- alloc = size + BUFSIZE;
- buf = realloc (buf, alloc);
- if (buf == NULL)
- {
- fprintf (stderr, "out of memory\n");
- exit (1);
- }
- }
+ {
+ alloc = alloc + alloc / 2;
+ if (alloc < size + BUFSIZE)
+ alloc = size + BUFSIZE;
+ buf = realloc (buf, alloc);
+ if (buf == NULL)
+ {
+ fprintf (stderr, "out of memory\n");
+ exit (1);
+ }
+ }
count = fread (buf + size, 1, BUFSIZE, stream);
if (count == 0)
- {
- if (ferror (stream))
- {
- perror ("fread");
- exit (1);
- }
- }
+ {
+ if (ferror (stream))
+ {
+ perror ("fread");
+ exit (1);
+ }
+ }
else
- size += count;
+ size += count;
}
buf = realloc (buf, size + 1);
if (buf == NULL)
@@ -185,21 +185,21 @@ main (int argc, char * argv[])
ulc_possible_linebreaks (input, length, locale_charset (), breaks);
for (i = 0; i < length; i++)
- {
- switch (breaks[i])
- {
- case UC_BREAK_POSSIBLE:
- putc ('|', stdout);
- break;
- case UC_BREAK_MANDATORY:
- break;
- case UC_BREAK_PROHIBITED:
- break;
- default:
- abort ();
- }
- putc (input[i], stdout);
- }
+ {
+ switch (breaks[i])
+ {
+ case UC_BREAK_POSSIBLE:
+ putc ('|', stdout);
+ break;
+ case UC_BREAK_MANDATORY:
+ break;
+ case UC_BREAK_PROHIBITED:
+ break;
+ default:
+ abort ();
+ }
+ putc (input[i], stdout);
+ }
free (breaks);
diff --git a/lib/unilbrk/ulc-width-linebreaks.c b/lib/unilbrk/ulc-width-linebreaks.c
index 3b091bf..16b3881 100644
--- a/lib/unilbrk/ulc-width-linebreaks.c
+++ b/lib/unilbrk/ulc-width-linebreaks.c
@@ -1,5 +1,5 @@
/* Line breaking of strings.
- Copyright (C) 2001-2003, 2006-2009 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
@@ -42,94 +42,94 @@
int
ulc_width_linebreaks (const char *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)
{
if (n > 0)
{
if (is_utf8_encoding (encoding))
- return u8_width_linebreaks ((const uint8_t *) s, n, width, start_column, at_end_columns, o, encoding, p);
+ return u8_width_linebreaks ((const uint8_t *) s, n, width, start_column, at_end_columns, o, encoding, p);
else
- {
- /* Convert the string to UTF-8 and build a translation table
- from offsets into s to offsets into the translated string. */
- size_t *offsets = (size_t *) malloc (n * sizeof (size_t));
-
- if (offsets != NULL)
- {
- uint8_t *t;
- size_t m;
-
- t = u8_conv_from_encoding (encoding, iconveh_question_mark,
- s, n, offsets, NULL, &m);
- if (t != NULL)
- {
- char *memory =
- (char *) (m > 0 ? malloc (m + (o != NULL ? m : 0)) : NULL);
-
- if (m == 0 || memory != NULL)
- {
- char *q = (char *) memory;
- char *o8 = (o != NULL ? (char *) (q + m) : NULL);
- int res_column;
- size_t i;
-
- /* Translate the overrides to the UTF-8 string. */
- if (o != NULL)
- {
- memset (o8, UC_BREAK_UNDEFINED, m);
- for (i = 0; i < n; i++)
- if (offsets[i] != (size_t)(-1))
- o8[offsets[i]] = o[i];
- }
-
- /* Determine the line breaks of the UTF-8 string. */
- res_column =
- u8_width_linebreaks (t, m, width, start_column, at_end_columns, o8, encoding, q);
-
- /* Translate the result back to the original string. */
- memset (p, UC_BREAK_PROHIBITED, n);
- for (i = 0; i < n; i++)
- if (offsets[i] != (size_t)(-1))
- p[i] = q[offsets[i]];
-
- free (memory);
- free (t);
- free (offsets);
- return res_column;
- }
- free (t);
- }
- free (offsets);
- }
- /* Impossible to convert. */
+ {
+ /* Convert the string to UTF-8 and build a translation table
+ from offsets into s to offsets into the translated string. */
+ size_t *offsets = (size_t *) malloc (n * sizeof (size_t));
+
+ if (offsets != NULL)
+ {
+ uint8_t *t;
+ size_t m;
+
+ t = u8_conv_from_encoding (encoding, iconveh_question_mark,
+ s, n, offsets, NULL, &m);
+ if (t != NULL)
+ {
+ char *memory =
+ (char *) (m > 0 ? malloc (m + (o != NULL ? m : 0)) : NULL);
+
+ if (m == 0 || memory != NULL)
+ {
+ char *q = (char *) memory;
+ char *o8 = (o != NULL ? (char *) (q + m) : NULL);
+ int res_column;
+ size_t i;
+
+ /* Translate the overrides to the UTF-8 string. */
+ if (o != NULL)
+ {
+ memset (o8, UC_BREAK_UNDEFINED, m);
+ for (i = 0; i < n; i++)
+ if (offsets[i] != (size_t)(-1))
+ o8[offsets[i]] = o[i];
+ }
+
+ /* Determine the line breaks of the UTF-8 string. */
+ res_column =
+ u8_width_linebreaks (t, m, width, start_column, at_end_columns, o8, encoding, q);
+
+ /* Translate the result back to the original string. */
+ memset (p, UC_BREAK_PROHIBITED, n);
+ for (i = 0; i < n; i++)
+ if (offsets[i] != (size_t)(-1))
+ p[i] = q[offsets[i]];
+
+ free (memory);
+ free (t);
+ free (offsets);
+ return res_column;
+ }
+ free (t);
+ }
+ free (offsets);
+ }
+ /* Impossible to convert. */
#if C_CTYPE_ASCII
- if (is_all_ascii (s, n))
- {
- /* ASCII is a subset of UTF-8. */
- return u8_width_linebreaks ((const uint8_t *) s, n, width, start_column, at_end_columns, o, encoding, p);
- }
+ if (is_all_ascii (s, n))
+ {
+ /* ASCII is a subset of UTF-8. */
+ return u8_width_linebreaks ((const uint8_t *) s, n, width, start_column, at_end_columns, o, encoding, p);
+ }
#endif
- /* We have a non-ASCII string and cannot convert it.
- Don't produce line breaks except those already present in the
- input string. All we assume here is that the encoding is
- minimally ASCII compatible. */
- {
- const char *s_end = s + n;
- while (s < s_end)
- {
- *p = ((o != NULL && *o == UC_BREAK_MANDATORY) || *s == '\n'
- ? UC_BREAK_MANDATORY
- : UC_BREAK_PROHIBITED);
- s++;
- p++;
- if (o != NULL)
- o++;
- }
- /* We cannot compute widths in this case. */
- }
- }
+ /* We have a non-ASCII string and cannot convert it.
+ Don't produce line breaks except those already present in the
+ input string. All we assume here is that the encoding is
+ minimally ASCII compatible. */
+ {
+ const char *s_end = s + n;
+ while (s < s_end)
+ {
+ *p = ((o != NULL && *o == UC_BREAK_MANDATORY) || *s == '\n'
+ ? UC_BREAK_MANDATORY
+ : UC_BREAK_PROHIBITED);
+ s++;
+ p++;
+ if (o != NULL)
+ o++;
+ }
+ /* We cannot compute widths in this case. */
+ }
+ }
}
return start_column;
}
@@ -154,28 +154,28 @@ read_file (FILE *stream)
while (! feof (stream))
{
if (size + BUFSIZE > alloc)
- {
- alloc = alloc + alloc / 2;
- if (alloc < size + BUFSIZE)
- alloc = size + BUFSIZE;
- buf = realloc (buf, alloc);
- if (buf == NULL)
- {
- fprintf (stderr, "out of memory\n");
- exit (1);
- }
- }
+ {
+ alloc = alloc + alloc / 2;
+ if (alloc < size + BUFSIZE)
+ alloc = size + BUFSIZE;
+ buf = realloc (buf, alloc);
+ if (buf == NULL)
+ {
+ fprintf (stderr, "out of memory\n");
+ exit (1);
+ }
+ }
count = fread (buf + size, 1, BUFSIZE, stream);
if (count == 0)
- {
- if (ferror (stream))
- {
- perror ("fread");
- exit (1);
- }
- }
+ {
+ if (ferror (stream))
+ {
+ perror ("fread");
+ exit (1);
+ }
+ }
else
- size += count;
+ size += count;
}
buf = realloc (buf, size + 1);
if (buf == NULL)
@@ -204,21 +204,21 @@ main (int argc, char * argv[])
ulc_width_linebreaks (input, length, width, 0, 0, NULL, locale_charset (), breaks);
for (i = 0; i < length; i++)
- {
- switch (breaks[i])
- {
- case UC_BREAK_POSSIBLE:
- putc ('\n', stdout);
- break;
- case UC_BREAK_MANDATORY:
- break;
- case UC_BREAK_PROHIBITED:
- break;
- default:
- abort ();
- }
- putc (input[i], stdout);
- }
+ {
+ switch (breaks[i])
+ {
+ case UC_BREAK_POSSIBLE:
+ putc ('\n', stdout);
+ break;
+ case UC_BREAK_MANDATORY:
+ break;
+ case UC_BREAK_PROHIBITED:
+ break;
+ default:
+ abort ();
+ }
+ putc (input[i], stdout);
+ }
free (breaks);