summaryrefslogtreecommitdiff
path: root/lib/uniconv
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2009-12-10 20:28:30 +0100
committerBruno Haible <bruno@clisp.org>2009-12-10 20:28:30 +0100
commit441aa3044f43e5572f58c354f01e6bc070acd5c7 (patch)
treebef236e8058dd3469da28ffcd5a6a287222a4c50 /lib/uniconv
parent039ae97b8ae35a2446c5d62d72b21689c97da7e2 (diff)
downloadgnulib-441aa3044f43e5572f58c354f01e6bc070acd5c7.tar.gz
Use spaces for indentation, not tabs.
Diffstat (limited to 'lib/uniconv')
-rw-r--r--lib/uniconv/u-conv-from-enc.h42
-rw-r--r--lib/uniconv/u-conv-to-enc.h90
-rw-r--r--lib/uniconv/u-strconv-from-enc.h6
-rw-r--r--lib/uniconv/u-strconv-to-enc.h16
-rw-r--r--lib/uniconv/u16-conv-to-enc.c104
-rw-r--r--lib/uniconv/u8-conv-from-enc.c84
-rw-r--r--lib/uniconv/u8-conv-to-enc.c58
-rw-r--r--lib/uniconv/u8-strconv-to-enc.c40
8 files changed, 220 insertions, 220 deletions
diff --git a/lib/uniconv/u-conv-from-enc.h b/lib/uniconv/u-conv-from-enc.h
index fa0f0d3dcb..aefade5bbc 100644
--- a/lib/uniconv/u-conv-from-enc.h
+++ b/lib/uniconv/u-conv-from-enc.h
@@ -26,7 +26,7 @@ FUNC (const char *fromcode,
size_t length = *lengthp * sizeof (UNIT);
if (mem_iconveha (src, srclen, fromcode, UTF_NAME, true, handler,
- offsets, &result, &length) < 0)
+ offsets, &result, &length) < 0)
return NULL;
if (offsets != NULL)
{
@@ -35,8 +35,8 @@ FUNC (const char *fromcode,
size_t *o;
for (o = offsets; o < offsets_end; o++)
- if (*o != (size_t)(-1))
- *o = *o / sizeof (UNIT);
+ if (*o != (size_t)(-1))
+ *o = *o / sizeof (UNIT);
}
if ((length % sizeof (UNIT)) != 0)
abort ();
@@ -49,7 +49,7 @@ FUNC (const char *fromcode,
utf8_string =
u8_conv_from_encoding (fromcode, handler, src, srclen, offsets,
- NULL, &utf8_length);
+ NULL, &utf8_length);
if (utf8_string == NULL)
return NULL;
result = U8_TO_U (utf8_string, utf8_length, resultbuf, lengthp);
@@ -65,25 +65,25 @@ FUNC (const char *fromcode,
size_t length = *lengthp;
size_t *offsets_end = offsets + srclen;
size_t *o;
- size_t off8 = 0; /* offset into utf8_string */
- size_t offunit = 0; /* offset into result */
+ size_t off8 = 0; /* offset into utf8_string */
+ size_t offunit = 0; /* offset into result */
for (o = offsets; o < offsets_end; o++)
- if (*o != (size_t)(-1))
- {
- while (off8 < *o)
- {
- int count8 = u8_mblen (utf8_string + off8, utf8_length - off8);
- int countunit = U_MBLEN (result + offunit, length - offunit);
- if (count8 < 0 || countunit < 0)
- abort ();
- off8 += count8;
- offunit += countunit;
- }
- if (*o != off8)
- abort ();
- *o = offunit;
- }
+ if (*o != (size_t)(-1))
+ {
+ while (off8 < *o)
+ {
+ int count8 = u8_mblen (utf8_string + off8, utf8_length - off8);
+ int countunit = U_MBLEN (result + offunit, length - offunit);
+ if (count8 < 0 || countunit < 0)
+ abort ();
+ off8 += count8;
+ offunit += countunit;
+ }
+ if (*o != off8)
+ abort ();
+ *o = offunit;
+ }
}
free (utf8_string);
return result;
diff --git a/lib/uniconv/u-conv-to-enc.h b/lib/uniconv/u-conv-to-enc.h
index ed715482a2..7478d94e50 100644
--- a/lib/uniconv/u-conv-to-enc.h
+++ b/lib/uniconv/u-conv-to-enc.h
@@ -29,12 +29,12 @@ FUNC (const char *tocode,
if (offsets != NULL && srclen > 0)
{
scaled_offsets =
- (size_t *) malloc (srclen * sizeof (UNIT) * sizeof (size_t));
+ (size_t *) malloc (srclen * sizeof (UNIT) * sizeof (size_t));
if (scaled_offsets == NULL)
- {
- errno = ENOMEM;
- return NULL;
- }
+ {
+ errno = ENOMEM;
+ return NULL;
+ }
}
else
scaled_offsets = NULL;
@@ -42,9 +42,9 @@ FUNC (const char *tocode,
result = resultbuf;
length = *lengthp;
if (mem_iconveha ((const char *) src, srclen * sizeof (UNIT),
- UTF_NAME, tocode,
- handler == iconveh_question_mark, handler,
- scaled_offsets, &result, &length) < 0)
+ UTF_NAME, tocode,
+ handler == iconveh_question_mark, handler,
+ scaled_offsets, &result, &length) < 0)
{
int saved_errno = errno;
free (scaled_offsets);
@@ -55,11 +55,11 @@ FUNC (const char *tocode,
if (offsets != NULL)
{
/* Convert scaled_offsets[srclen * sizeof (UNIT)] to
- offsets[srclen]. */
+ offsets[srclen]. */
size_t i;
for (i = 0; i < srclen; i++)
- offsets[i] = scaled_offsets[i * sizeof (UNIT)];
+ offsets[i] = scaled_offsets[i * sizeof (UNIT)];
free (scaled_offsets);
}
@@ -67,10 +67,10 @@ FUNC (const char *tocode,
{
result = (char *) malloc (1);
if (result == NULL)
- {
- errno = ENOMEM;
- return NULL;
- }
+ {
+ errno = ENOMEM;
+ return NULL;
+ }
}
*lengthp = length;
return result;
@@ -91,62 +91,62 @@ FUNC (const char *tocode,
{
scaled_offsets = (size_t *) malloc (utf8_srclen * sizeof (size_t));
if (scaled_offsets == NULL)
- {
- if (utf8_src != tmpbuf)
- free (utf8_src);
- errno = ENOMEM;
- return NULL;
- }
+ {
+ if (utf8_src != tmpbuf)
+ free (utf8_src);
+ errno = ENOMEM;
+ return NULL;
+ }
}
else
scaled_offsets = NULL;
result = u8_conv_to_encoding (tocode, handler, utf8_src, utf8_srclen,
- scaled_offsets, resultbuf, lengthp);
+ scaled_offsets, resultbuf, lengthp);
if (result == NULL)
{
int saved_errno = errno;
free (scaled_offsets);
if (utf8_src != tmpbuf)
- free (utf8_src);
+ free (utf8_src);
errno = saved_errno;
return NULL;
}
if (offsets != NULL)
{
- size_t iunit; /* offset into src */
- size_t i8; /* offset into utf8_src */
+ size_t iunit; /* offset into src */
+ size_t i8; /* offset into utf8_src */
for (iunit = 0; iunit < srclen; iunit++)
- offsets[iunit] = (size_t)(-1);
+ offsets[iunit] = (size_t)(-1);
iunit = 0;
i8 = 0;
while (iunit < srclen && i8 < utf8_srclen)
- {
- int countunit;
- int count8;
-
- offsets[iunit] = scaled_offsets[i8];
-
- countunit = U_MBLEN (src + iunit, srclen - iunit);
- count8 = u8_mblen (utf8_src + i8, utf8_srclen - i8);
- if (countunit < 0 || count8 < 0)
- abort ();
- iunit += countunit;
- i8 += count8;
- }
+ {
+ int countunit;
+ int count8;
+
+ offsets[iunit] = scaled_offsets[i8];
+
+ countunit = U_MBLEN (src + iunit, srclen - iunit);
+ count8 = u8_mblen (utf8_src + i8, utf8_srclen - i8);
+ if (countunit < 0 || count8 < 0)
+ abort ();
+ iunit += countunit;
+ i8 += count8;
+ }
/* Check that utf8_src has been traversed entirely. */
if (i8 < utf8_srclen)
- abort ();
+ abort ();
/* Check that src has been traversed entirely, except possibly for an
- incomplete sequence of units at the end. */
+ incomplete sequence of units at the end. */
if (iunit < srclen)
- {
- offsets[iunit] = *lengthp;
- if (!(U_MBLEN (src + iunit, srclen - iunit) < 0))
- abort ();
- }
+ {
+ offsets[iunit] = *lengthp;
+ if (!(U_MBLEN (src + iunit, srclen - iunit) < 0))
+ abort ();
+ }
free (scaled_offsets);
}
if (utf8_src != tmpbuf)
diff --git a/lib/uniconv/u-strconv-from-enc.h b/lib/uniconv/u-strconv-from-enc.h
index 25813c76dc..667f344abc 100644
--- a/lib/uniconv/u-strconv-from-enc.h
+++ b/lib/uniconv/u-strconv-from-enc.h
@@ -24,13 +24,13 @@ FUNC (const char *string,
result =
U_CONV_FROM_ENCODING (fromcode, handler,
- string, strlen (string) + 1, NULL,
- NULL, &length);
+ string, strlen (string) + 1, NULL,
+ NULL, &length);
if (result == NULL)
return NULL;
/* Verify the result has exactly one NUL unit, at the end. */
if (!(length > 0 && result[length-1] == 0
- && U_STRLEN (result) == length-1))
+ && U_STRLEN (result) == length-1))
{
free (result);
errno = EILSEQ;
diff --git a/lib/uniconv/u-strconv-to-enc.h b/lib/uniconv/u-strconv-to-enc.h
index b6e6ebb5d8..d4f63905e2 100644
--- a/lib/uniconv/u-strconv-to-enc.h
+++ b/lib/uniconv/u-strconv-to-enc.h
@@ -24,9 +24,9 @@ FUNC (const UNIT *string,
size_t length = 0;
if (mem_iconveha ((const char *) string, (U_STRLEN (string) + 1) * sizeof (UNIT),
- UTF_NAME, tocode,
- handler == iconveh_question_mark, handler,
- NULL, &result, &length) < 0)
+ UTF_NAME, tocode,
+ handler == iconveh_question_mark, handler,
+ NULL, &result, &length) < 0)
return NULL;
/* Verify the result has exactly one NUL byte, at the end. */
if (!(length > 0 && result[length-1] == '\0' && strlen (result) == length-1))
@@ -49,11 +49,11 @@ FUNC (const UNIT *string,
if (result == NULL)
{
if (utf8_string != tmpbuf)
- {
- int saved_errno = errno;
- free (utf8_string);
- errno = saved_errno;
- }
+ {
+ int saved_errno = errno;
+ free (utf8_string);
+ errno = saved_errno;
+ }
return NULL;
}
if (utf8_string != tmpbuf)
diff --git a/lib/uniconv/u16-conv-to-enc.c b/lib/uniconv/u16-conv-to-enc.c
index ba70736cfd..4865a1ea66 100644
--- a/lib/uniconv/u16-conv-to-enc.c
+++ b/lib/uniconv/u16-conv-to-enc.c
@@ -81,69 +81,69 @@ FUNC (const SRC_UNIT *s, size_t n, DST_UNIT *resultbuf, size_t *lengthp)
/* Fetch a Unicode character from the input string. */
count = u16_mbtoucr (&uc, s, s_end - s);
if (count < 0)
- {
- if (count == -2)
- /* Incomplete sequence of units. */
- break;
- if (!(result == resultbuf || result == NULL))
- free (result);
- errno = EILSEQ;
- return NULL;
- }
+ {
+ if (count == -2)
+ /* Incomplete sequence of units. */
+ break;
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ errno = EILSEQ;
+ return NULL;
+ }
s += count;
/* Store it in the output string. */
count = u8_uctomb (result + length, uc, allocated - length);
if (count == -1)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- errno = EILSEQ;
- return NULL;
- }
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ errno = EILSEQ;
+ return NULL;
+ }
if (count == -2)
- {
- DST_UNIT *memory;
-
- allocated = (allocated > 0 ? 2 * allocated : 12);
- if (length + 6 > allocated)
- allocated = length + 6;
- if (result == resultbuf || result == NULL)
- memory = (DST_UNIT *) malloc (allocated * sizeof (DST_UNIT));
- else
- memory =
- (DST_UNIT *) realloc (result, allocated * sizeof (DST_UNIT));
-
- if (memory == NULL)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- errno = ENOMEM;
- return NULL;
- }
- if (result == resultbuf && length > 0)
- memcpy ((char *) memory, (char *) result,
- length * sizeof (DST_UNIT));
- result = memory;
- count = u8_uctomb (result + length, uc, allocated - length);
- if (count < 0)
- abort ();
- }
+ {
+ DST_UNIT *memory;
+
+ allocated = (allocated > 0 ? 2 * allocated : 12);
+ if (length + 6 > allocated)
+ allocated = length + 6;
+ if (result == resultbuf || result == NULL)
+ memory = (DST_UNIT *) malloc (allocated * sizeof (DST_UNIT));
+ else
+ memory =
+ (DST_UNIT *) realloc (result, allocated * sizeof (DST_UNIT));
+
+ if (memory == NULL)
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ errno = ENOMEM;
+ return NULL;
+ }
+ if (result == resultbuf && length > 0)
+ memcpy ((char *) memory, (char *) result,
+ length * sizeof (DST_UNIT));
+ result = memory;
+ count = u8_uctomb (result + length, uc, allocated - length);
+ if (count < 0)
+ abort ();
+ }
length += count;
}
if (length == 0)
{
if (result == NULL)
- {
- /* Return a non-NULL value. NULL means error. */
- result = (DST_UNIT *) malloc (1);
- if (result == NULL)
- {
- errno = ENOMEM;
- return NULL;
- }
- }
+ {
+ /* Return a non-NULL value. NULL means error. */
+ result = (DST_UNIT *) malloc (1);
+ if (result == NULL)
+ {
+ errno = ENOMEM;
+ return NULL;
+ }
+ }
}
else if (result != resultbuf && length < allocated)
{
@@ -152,7 +152,7 @@ FUNC (const SRC_UNIT *s, size_t n, DST_UNIT *resultbuf, size_t *lengthp)
memory = (DST_UNIT *) realloc (result, length * sizeof (DST_UNIT));
if (memory != NULL)
- result = memory;
+ result = memory;
}
*lengthp = length;
diff --git a/lib/uniconv/u8-conv-from-enc.c b/lib/uniconv/u8-conv-from-enc.c
index 7605e63e75..59248388c7 100644
--- a/lib/uniconv/u8-conv-from-enc.c
+++ b/lib/uniconv/u8-conv-from-enc.c
@@ -31,10 +31,10 @@
uint8_t *
u8_conv_from_encoding (const char *fromcode,
- enum iconv_ilseq_handler handler,
- const char *src, size_t srclen,
- size_t *offsets,
- uint8_t *resultbuf, size_t *lengthp)
+ enum iconv_ilseq_handler handler,
+ const char *src, size_t srclen,
+ size_t *offsets,
+ uint8_t *resultbuf, size_t *lengthp)
{
if (STRCASEEQ (fromcode, "UTF-8", 'U','T','F','-','8',0,0,0,0))
{
@@ -42,40 +42,40 @@ u8_conv_from_encoding (const char *fromcode,
uint8_t *result;
if (u8_check ((const uint8_t *) src, srclen))
- {
- errno = EILSEQ;
- return NULL;
- }
+ {
+ errno = EILSEQ;
+ return NULL;
+ }
if (offsets != NULL)
- {
- size_t i;
-
- for (i = 0; i < srclen; )
- {
- int count = u8_mblen ((const uint8_t *) src + i, srclen - i);
- /* We can rely on count > 0 because of the previous u8_check. */
- if (count <= 0)
- abort ();
- offsets[i] = i;
- i++;
- while (--count > 0)
- offsets[i++] = (size_t)(-1);
- }
- }
+ {
+ size_t i;
+
+ for (i = 0; i < srclen; )
+ {
+ int count = u8_mblen ((const uint8_t *) src + i, srclen - i);
+ /* We can rely on count > 0 because of the previous u8_check. */
+ if (count <= 0)
+ abort ();
+ offsets[i] = i;
+ i++;
+ while (--count > 0)
+ offsets[i++] = (size_t)(-1);
+ }
+ }
/* Memory allocation. */
if (resultbuf != NULL && *lengthp >= srclen)
- result = resultbuf;
+ result = resultbuf;
else
- {
- result = (uint8_t *) malloc (srclen > 0 ? srclen : 1);
- if (result == NULL)
- {
- errno = ENOMEM;
- return NULL;
- }
- }
+ {
+ result = (uint8_t *) malloc (srclen > 0 ? srclen : 1);
+ if (result == NULL)
+ {
+ errno = ENOMEM;
+ return NULL;
+ }
+ }
memcpy ((char *) result, src, srclen);
*lengthp = srclen;
@@ -87,18 +87,18 @@ u8_conv_from_encoding (const char *fromcode,
size_t length = *lengthp;
if (mem_iconveha (src, srclen, fromcode, "UTF-8", true, handler,
- offsets, &result, &length) < 0)
- return NULL;
+ offsets, &result, &length) < 0)
+ return NULL;
if (result == NULL) /* when (resultbuf == NULL && length == 0) */
- {
- result = (char *) malloc (1);
- if (result == NULL)
- {
- errno = ENOMEM;
- return NULL;
- }
- }
+ {
+ result = (char *) malloc (1);
+ if (result == NULL)
+ {
+ errno = ENOMEM;
+ return NULL;
+ }
+ }
*lengthp = length;
return (uint8_t *) result;
}
diff --git a/lib/uniconv/u8-conv-to-enc.c b/lib/uniconv/u8-conv-to-enc.c
index 90acccec1c..29a8a534d9 100644
--- a/lib/uniconv/u8-conv-to-enc.c
+++ b/lib/uniconv/u8-conv-to-enc.c
@@ -31,10 +31,10 @@
char *
u8_conv_to_encoding (const char *tocode,
- enum iconv_ilseq_handler handler,
- const uint8_t *src, size_t srclen,
- size_t *offsets,
- char *resultbuf, size_t *lengthp)
+ enum iconv_ilseq_handler handler,
+ const uint8_t *src, size_t srclen,
+ size_t *offsets,
+ char *resultbuf, size_t *lengthp)
{
if (STRCASEEQ (tocode, "UTF-8", 'U','T','F','-','8',0,0,0,0))
{
@@ -43,24 +43,24 @@ u8_conv_to_encoding (const char *tocode,
/* Conversion from UTF-8 to UTF-8. No need to go through iconv(). */
#if CONFIG_UNICODE_SAFETY
if (u8_check (src, srclen))
- {
- errno = EILSEQ;
- return NULL;
- }
+ {
+ errno = EILSEQ;
+ return NULL;
+ }
#endif
/* Memory allocation. */
if (resultbuf != NULL && *lengthp >= srclen)
- result = resultbuf;
+ result = resultbuf;
else
- {
- result = (char *) malloc (srclen > 0 ? srclen : 1);
- if (result == NULL)
- {
- errno = ENOMEM;
- return NULL;
- }
- }
+ {
+ result = (char *) malloc (srclen > 0 ? srclen : 1);
+ if (result == NULL)
+ {
+ errno = ENOMEM;
+ return NULL;
+ }
+ }
memcpy (result, (const char *) src, srclen);
*lengthp = srclen;
@@ -72,20 +72,20 @@ u8_conv_to_encoding (const char *tocode,
size_t length = *lengthp;
if (mem_iconveha ((const char *) src, srclen,
- "UTF-8", tocode,
- handler == iconveh_question_mark, handler,
- offsets, &result, &length) < 0)
- return NULL;
+ "UTF-8", tocode,
+ handler == iconveh_question_mark, handler,
+ offsets, &result, &length) < 0)
+ return NULL;
if (result == NULL) /* when (resultbuf == NULL && length == 0) */
- {
- result = (char *) malloc (1);
- if (result == NULL)
- {
- errno = ENOMEM;
- return NULL;
- }
- }
+ {
+ result = (char *) malloc (1);
+ if (result == NULL)
+ {
+ errno = ENOMEM;
+ return NULL;
+ }
+ }
*lengthp = length;
return result;
}
diff --git a/lib/uniconv/u8-strconv-to-enc.c b/lib/uniconv/u8-strconv-to-enc.c
index a3f12b6b1e..0823348439 100644
--- a/lib/uniconv/u8-strconv-to-enc.c
+++ b/lib/uniconv/u8-strconv-to-enc.c
@@ -31,8 +31,8 @@
char *
u8_strconv_to_encoding (const uint8_t *string,
- const char *tocode,
- enum iconv_ilseq_handler handler)
+ const char *tocode,
+ enum iconv_ilseq_handler handler)
{
char *result;
size_t length;
@@ -43,17 +43,17 @@ u8_strconv_to_encoding (const uint8_t *string,
length = u8_strlen (string) + 1;
#if CONFIG_UNICODE_SAFETY
if (u8_check (string, length))
- {
- errno = EILSEQ;
- return NULL;
- }
+ {
+ errno = EILSEQ;
+ return NULL;
+ }
#endif
result = (char *) malloc (length);
if (result == NULL)
- {
- errno = ENOMEM;
- return NULL;
- }
+ {
+ errno = ENOMEM;
+ return NULL;
+ }
memcpy (result, (const char *) string, length);
return result;
}
@@ -62,18 +62,18 @@ u8_strconv_to_encoding (const uint8_t *string,
result = NULL;
length = 0;
if (mem_iconveha ((const char *) string, u8_strlen (string) + 1,
- "UTF-8", tocode,
- handler == iconveh_question_mark, handler,
- NULL, &result, &length) < 0)
- return NULL;
+ "UTF-8", tocode,
+ handler == iconveh_question_mark, handler,
+ NULL, &result, &length) < 0)
+ return NULL;
/* Verify the result has exactly one NUL byte, at the end. */
if (!(length > 0 && result[length-1] == '\0'
- && strlen (result) == length-1))
- {
- free (result);
- errno = EILSEQ;
- return NULL;
- }
+ && strlen (result) == length-1))
+ {
+ free (result);
+ errno = EILSEQ;
+ return NULL;
+ }
return result;
}
}